Tuesday, August 9. 2005
Today I made the first release of HTTP_Cache on 3rdPEARty.net, the channel server provided by Carsten Lucke. If you are already using HTTP_Cache, please change your installations and register the new channel-server:
$ pear channel-discover 3rdpearty.net
$ pear install 3p/HTTP_Cache
If you are already using HTTP_Cache, make sure to uninstall it beforehand to avoid conflicts:
$ pear uninstall pat/HTTP_Cache3rdPEARty.net is relatively new and will provide packages by several PEAR and PAT developers that are not available in the PEAR repository, more on this subject will probably follow soon by Carsten. I moved HTTP_Cache to this server, so that the PAT server will only provide packages prefixed with pat. Other packages available at 3rdPEARty are Util_Checksum, which is able to generate various checksums as well as a package that provides commonly used exceptions, called P3AR_Exception.
Monday, August 8. 2005
As I'm currently using Java a lot at work (90% of the time), I started porting some of the classes, that I use a lot to Java and make them available to the public under an open source license. Most of the time, you only read of projects ported from Java to PHP, but I think the PHP community offers a lot of projects which currently are not available in Java and a lot of Java developers can learn a lot from PHP.
The first two projects I ported are patConfiguration, which is now named XJConf and Event_Dispatcher (now called EventDispatcher). XJConf allows you to map any XML document to Java objects by defining rules for the mapping process. These rules allow you to call setter-methods and the constructor and define the classes used for the tags and attributes. It also is extendible using XML namespaces, I already implemented basic XInclude support. XJConf is a lot more powerful than the PHP version, but I plan to port the new features back to a PHP5-only version of patConfiguration.
EventDispatcher is a package that helps you build event-centered applications by dispatching the event-objects to the listeners that have been registered for the various objects. The package provides almost the same functionality as the PHP version, which has been developed by Bertrand Mansion and myself.
Documentation for both packages is available at my new website java.schst.net, which also provides a web-SVN viewer, ticketing system, a roadmap and many other features (powered by Trac). Currently there aren't any ready-to-use JAR files, but you can get them from SVN and build them using ant.
Sunday, July 17. 2005
As some of you may have noticed, our forum at http://forum.php-tools.net has been offline for the last two weeks. The cause has been that someone hacked our server and used it for file-sharing which caused a lot of traffic, which we have to pay for. As the hacker used a security hole in phpBB (which has been fixed in newer versions, but our installation wasn't up to date), which we used as a forum software, we decided to disable or forum until we had evaluated, whether to install a different software.
Since today, our forum is back online, but we switched from phpBB to FUDForum, as we experienced several problems with phpBB during the last year and FUDForum seems to be a lot more secure. Thanks to a lot of help from Ilia, I also was able to import all userdata and all postings from the old software so you can still login with the same username and read the old postings. A big "THANK YOU" for this from the pat team to Ilia, this has been the best support we experienced for an open-source product.
Saturday, June 25. 2005
 Just in time for the LinuxTag 2005 O'Reilly Germany released the "PHP5 Kochbuch". This is a new edition of the translation of the original PHP cookbook by Adam Trachtenberg and David Sklar.
For the new revision which now completely focusses on PHP5 I contributed four chapters: XML, Webservices, PEAR and "PHP on the commandline".
These chapters deal with all new features of PHP5 like the new DOM, XSL and SOAP extensions, but also with some features that will only be included in PHP 5.1 like xmlReader and xmlWriter and even the brand-new XML-RPCi extension in PECL. Through all my chapters I'm also making constant use of PEAR packages like Net_Server, XML_Serializer, XML_RPC or Services_Ebay. The PEAR chapter itself even deals with PEAR 1.4.0 and explains you how to set-up a channel server. If you read the book, I'm happy to receive any feedback on my work.
Monday, June 6. 2005
Although the Call-for-Papers for the International PHP Conference 2005 in Frankfurt has just been anounced I won't be submitting any sessions this year. But of course neither the conference nor the organizers are responsible (the conference has been great all the past years), but at the time the conference takes place, I'll be in my honeymoon on Hawaii after getting married in Las Vegas in the first week of November. I bet, this experience will sure beat another PHP conference, although I won't be able to meet all of the PHP folks I regularly meet there like Christian, Toby, Aaron as well as a whole bunch of PEAR-developers.
For the same reasons I did not propose any sessions for any of the upcoming conferences, I'll hopefully ba back, next year (At least, I do not plan to getting married again...)
Sunday, June 5. 2005
I just released HTTP_Cache 0.1.0 through our own PEAR-Channel at pear.php-tools.net. I proposed this package via PEPr some time ago, but because some of the functionality already is available in the packages HTTP_Header and HTTP_Download I never initiated the call for votes. But still I think this small package is quite useful when you need HTTP-Caching using ETag. As it supplies a handler for PHP's output buffering all you need to add to your scripts are two lines of code:
require_once 'HTTP/Cache.php';
$cache = &new HTTP_Cache(array('auto' => true));
echo "You now may send any data to the browser";
If a user now requests this page twice, it will be only sent to the browser once, unless the output has changed in the meantime.
If you are using PEAR 1.4 installing the package is nearly as easy as installing a package from PEAR:
$ pear channel-discover pear.php-tools.net
$ pear install pat/HTTP_Cache
The package will be get installed in the PEAR directory of you server and you can instantly start to use it.
Thursday, May 5. 2005
I just released the next alpha version of patForms, our form generation and validation package. This release contains some small bugfixes as well as a feature request from Helgi.
One of the coolest features of patForms is that you may embedd your form elements using XML tags directly in HTML files, like web controls in ASP.Net or Java Server Faces. patForms will then parse the HTML code and creates PHP objects from the embedded components that interact with the data the user submitted and automatically serializes them back at the end of the request. Other features are support for event-driven development and the subject/observer pattern to get rid of spaghetti code. Furthermore patForms provides custom filters and rules for the user input and is easily extendible.
Starting with this version, patForms is now also available through our PEAR channel, which makes the installation quite easy (if you have PEAR 1.4.0a11 or higher installed):
$ pear channel-discover pear.php-tools.net
$ pear install --alldeps pat/patForms
patForms also gets more and more acceptance in the community, currently there's work done on a patForms / Propel integration by Sven Fuchs and some other developers. This will allow you to build forms from Propel objects that automatically load and save data from and to the database. You can read more about these plans in the weblog of Sven. There's already some working code available and we expect a release of this quite soon.
Wednesday, May 4. 2005
Stephan uploaded the slides for his two talks on the International PHP Conference in Amsterdam yesterday evening. Apparently both sessions were well attended, and the Power Workshop on XML and WebServices he has made along with Tobias Schlitt went quite well
You can have a look at the slides for Stephan's talks right here:
Go OO! - Real-life Design Patterns in PHP5
Component and Event Based Architectures
The examples are not included yet, but we will add them as a separate package soon.
Friday, April 22. 2005
This week, this latest issue of the PHP Magazine International Edition has been released. This issue contains the second part of my "Go OO!" series which deals with design patterns in PHP5. If you are interested in decorators, iterators or the delegation pattern, make sure to buy a copy. Sebastian also contributed his first article and shows you how patForms can be a timesaver when creating form-based user interfaces. And last but not least, Carsten Lucke (another pat-related developer and friend) showcases his PEAR package Date_Holidays. And of course there a a lot of other interesting topics covered.
Tuesday, April 12. 2005
We are currently planning a complete relaunch of the php-tools.net site, and would welcome any feedback on how we can improve it in the process. The new site will have a completely new design and backend (we are still deciding what we will use), but even though we have a good idea of what featureset the new site will need, you can still help. Tell us what you least and most liked about the current site, and what features you missed most: simply send a mail to argh [at] php-tools [dot] net with your ideas / criticism / feature requests.
Thanks in advance from the Team!
Wednesday, April 6. 2005
Since Greg Beaver invented the PEAR_Server class and Davey Shafik created a handy package to set up your own Channel frontend, we've been itching to make a pat Channel. Stephan installed it on pear.php-tools.net, and after my designer eyes stopped bleeding when I saw the default layout of the beast (don't get me wrong, Davey - I know it's just an example layout  ), I made a pat-skin and now it's ready to roll.
For the moment only a few of our packages are available through our channel, but we'll add the others eveventually.
You can read more about the PEAR_Server package on Greg's blog, and more about the Channel frontend package on Davey's blog.
Yesterday I released patTemplate 3.1.0a1, the first alpha version of the 3.1 branch of my templating engine. This release provides dozens of new features and although it's labelled alpha, it's nearly production quality. I'm currently using it in one of my projects, that servers 400.000 visitors a day.
patConfiguration 2.0.0b2 mainly contains some bugfixes and is supposed to be the last beta version before I'm going stable. If you are using any of these, please test the new versions and report any bugs you find.
If you are using PEAR 1.4.0 you can also get them from our channel server.
Monday, March 7. 2005
I just made a bugfix release of the patTemplate 3.0.x branch, which fixes some small notices and bugs that have been reported in the last few months. If you are using patTemplate 3.0.0 I recommend you to upgrade.
If you would like to test some of the new features I have added to patTemplate you may grab the latest snapshot of the 3.1.x series from snap.php-tools.net.
Sunday, March 6. 2005
I finally managed to release a first public beta of my configuration reader patConfiguration.
Starting with this release it is now driver-based which keeps the codebase small and at the same time allows you to read and write XML, INI and WDDX files using the same API. The XML-reader is the most powerful driver as it allows you to define how you would like the tags to be handled. This means you can define that the tag <foo one="1" bar="totmato"/> should automatically be converted to an array that should contain the attributes of the tag as values. Of course you can also choose which types to use for the attribute values, so they get converted to booleans, floats, integers, strings, arrays or objects.
To achieve this, patConfiguration provides a very easy-to-use built-in tag:
<!-- define a new namespace -->
<define ns="shop">
<!-- define a tag in the namespace -->
<define tag="articles" type="array"/>
<!-- Define a tag with no name (indexed array) -->
<define tag="article" name="_none" type="array">
<!-- define three attributes for this tag -->
<define attribute="vendor" type="string"/>
<define attribute="title" type="string"/>
<define attribute="price" type="float" default="99.99"/>
</define>
</define>
Now that you've defined, how patConfiguration should interpret the tags, you may use them in your configuration:
<shop:articles>
<shop:article title="Power battery" vendor="Green Lantern"/>
<shop:article title="Batarang" vendor="Batman" price="500"/>
</shop:articles>
Parsing this configuration is extremely easy:
<?php
$conf = new patConfiguration(
array(
'configDir' => './config'
)
);
// parse config file
$conf->loadConfig('example_define_basic.xml');
$config = $conf->getConfigValue('articles');
?>
If you worry about the overhead of parsing XML files on every request, you may want to switch-on the caching system which makes loading the configuration faster then reading it from PHP files. If you want to use your tag definitions in more than one file, just use external entities or xInclude tags, patConfiguration supports both, even in PHP4.
After reading this XML-document with patConfiguration, you'll get the following array structure back:
Array
(
[0] => Array
(
[vendor] => Green Lantern
[title] => Power battery
[price] => 99.99
)
[1] => Array
(
[vendor] => Batman
[title] => Batarang
[price] => 500
)
)
patConfiguration allows you to return the complete configuration or only parts of it, using a mixture of PHP's array snytax and a path to the desired value. If you'd like to see more features of patConfiguration in action, you may want to take a look at the online examples or download it from our site.
If you are using PEAR 1.4.0 you may also get it from our PEAR-channel:
$ pear channel-discover pear.php-tools.net
$ pear install --alldeps pat/patConfiguration
If you stumble upon a bug, please report it using our bugtracker.
Friday, March 4. 2005
Our new member Daniel Wiegand (wiegi) implemented a PEAR compatible client for Yahoo's new REST-based webservice API. From the Yahoo developer site: "Yahoo! Search Web Services allow you to access Yahoo content and services in your favorite programming languages. This means you can now build Yahoo directly into your own applications." By using Daniel's PHP5 client you do not need to worry about the protocol or the resulting XML format, everything is done in plain PHP:
<?PHP $yahoo = new Services_Yahoo($appId); try { // do a simple search $result = $yahoo->searchWeb('PEAR'); echo "Total results returned: " . $result->getTotal() . "<br />\n"; foreach ($result as $entry) { printf('<a href="%s">%s</a><br />', $entry['ClickUrl'], $entry['Title']); printf('<i>%s</i><br /><br />', $entry['Summary']); } } catch (Services_Yahoo_Exception $e){ echo $e; } ?>
Besides searchWeb() the client provides more methods to use the different web services offered by Yahoo: - searchImages()
- searchVideos()
- searchNews
- searchLocal()
Each of the methods can be used with several parameters that need to be passed in a fixed parameter order or you may pass a associative array that contains any parameters you want to pass.
As Daniel has been using PHP5 all of these methods return a Services_Yahoo_Result object that provides methods to return the total number of search results but can be iterated like a normal object, thanks to SPL. This result object offers a lot more, as you can use it to fetch the next page using the same search parameters:
<?PHP $yahoo = new Services_Yahoo($appId); try { // do a simple search $result = $yahoo->searchWeb('Graceland'); printf("Total results returned: %d<br />\n", $result->getTotal()); printf("Fetching %d entries starting from %d.<br />\n", $result->getReturned(), $result->getCurrent()); foreach ($result as $entry) { printf('<a href="%s">%s</a><br />', $entry['ClickUrl'], $entry['Title']); printf('<i>%s</i><br /><br />', $entry['Summary']); } echo "Test, whether more entries are available....<br /><br />\n"; if ($result->hasNext()) { $result->fetchNext(); } printf("Fetching %d entries starting from %d.<br />\n", $result->getReturned(), $result->getCurrent()); foreach ($result as $entry) { printf('<a href="%s">%s</a><br />', $entry['ClickUrl'], $entry['Title']); printf('<i>%s</i><br /><br />', $entry['Summary']); } } catch (Services_Yahoo_Exception $e){ echo $e; } ?>Quite cool, isn't it?
You can take a loot at the sources at http://pear.php-tools.net/projects/Services_Yahoo/ or even download a PEAR installable package from http://pear.php-tools.net/projects/Services_Yahoo/Services_Yahoo-0.1.0.tgz (requires PHP5, XML_Serializer and HTTP_Request).
We would have loved to propose this to PEAR, but there already is a draft for a Services_Yahoo package by Martin Jansen, but until now he hasn't showed any of his code. Hopefully Daniel and Martin could be working on a package together.
|