Tuesday, November 30. 2004
I finally managed to release the stable version of my templating engine. It has been completely recoded for this release, as well as redesigned. Here's just a short list of the feature: - based on XML tags
- Very flexible architecture
- interchangable readers: read from files, string, other template formats
- input filters
- output filters
- variable modifiers
- easily extendible (bind PHP objects to tags)
- accepts strings, arrays and objects
- features conditions for special templates (odd, even, first or last repetition)
If you'd like to see a full list of features, you might want to take a look at the online examples or browse our blog.
If you're still not convinced to use patTemplate, maybe you should know, that the content management system Mambo started adopting patTemplate for their next major version.
To download the package, have a look at our site, or to be on the bleeding edge and give yourself some shivers, there's also the CVS snapshots.
I just released a new version of my PEAR package Services_Ebay, which is now marked as alpha as the API starts to stabilize.
This version includes some quite interesting new features: Services_Ebay now provides some kind of introspection, as you can get a list of all supported API calls using Services_Ebay::getAvailableCalls(). Furthermore it finally supports a changeable SiteId, that means it's not restricted to ebay.com anymore.
To help you debugging your application and to help me analysing the bug reports it's now also possible to capture the XML data that is sent to and recieved from the eBay webservice.
But the coolest new feature are the custom models, an idea I had in the Toby's and Lukas' powerworkshop. They used Services_Ebay in conjunction with some other PEAR packages, but wanted to store some additional information for the items in a database. To achieve this, they created a new object that stored a reference to a Services_Ebay_Model_Item object and the additional data that they wanted to store in the database. Although this worked, it did not look very nice and can get quite messy.
To achieve the same result, you may now create new model items to replace the ones provided by Services_Ebay. That means you can create classes for users, items, feedback etc. that will automatically created and filled with data by the Services_Ebay package. All you have to do is the following:
<?php;
require_once 'Services/Ebay.php';
// simple model class
// You may implement any additional methods you need
// in your custom models.
class myItem extends Services_Ebay_Model_Item
{
// Dummy method
// This does not really do anything, but you can implement whatever you like
// here...
public function StoreItem()
{
echo "Now you could store the item data in your local database...";
}
}
Services_Ebay::useModelClass('Item', 'myItem');
$session = Services_Ebay::getSession($devId, $appId, $certId);
$session->setToken($token);
$ebay = new Services_Ebay($session);
$item = $ebay->GetItem('4501296414');
$item->StoreItem();
?>
This is totally simple and allows you to add any functionality you need in your application without wrapping methods or duplicating code.
Inspired by Helgi's comment on patForms, I started a new approach to data filters in patForms.
patForms data filters are fore more powerful than input filters in other form processing tools, liek QuickForm. The possibilities of filters include: - Filters work in two directions, e.g. you can store seconds in database and let the user view and enter hours by applying a multiplier filter
- Filters can be applied before data is validated, I call these HTTP filters, as they sit between the browser and patForms
- Filters can be applied after data is validated, I call these PHP filters, as they sit between patForms and your application
Although this made filters an extremely cool feature, they are harder to use than filters in QuickForm, as each filter (indepentent of the real complexity) has to be an object and needs to be instantiated before it can be used, which led to the following code:
<?php
// create the trim filter
$filter =& patForms::createFilter( 'Trim' );
// get the element
$el =& $form->getElementByName( 'username' );
// apply the filter to the element
$el->applyFilter( $filter );
?>
Helgi complained that in most cases you'll probably just want to apply a built-in PHP function to the date that is sent from the user and that having to instantiate objects is overkill for this simple feature.
Today a nice idea popped to my mind: I created a new filter object that is able to apply any PHP function to the form data. Furthermore I created a wrapper function in the element base class which lets you instantiate and configure this object in a single method call. This reduces the necessary code while still maintaining the flexibilty we introduced by using filter objects:
<?php
// get the element
$el =& $form->getElementByName( 'username' );
// apply an HTTP filter for incoming data
$el->applySimpleFilter('strtolower');
?>
In addition to a function that filters incoming data, you may pass a second function that modifies the value before it is sent back to the browser. Of course applySimpleFilter() also accepts static methods or object methods instead of functions.
Monday, November 29. 2004
Our BBCode parser, patBBCode, ist available as v1.0.0beta. This small library is based on a SAX parser, and retrieves all tags with just one regular expression. The tag transformation is then done by filter objects, or patBBcode itself in case of 'basic' tags without attributes.
A complete documentation is available as well as a series of examples also included in the package for a quick start.
Some are already familiar with patBBCode, but with this release there are a few new things. Filter classes can now trigger their own user errors, e.g. if a vital attribute is missing. The biggest addition, however, is the Describer helper class: it enables you to describe an existing patBBCode object by retieving information about all available tags. This can be used to automatically generate a tag guide which you can retrieve in several output formats by means of a specific Driver object. The following bit of code generates an HTML table with a list of tags and their function:
// create the Describer
$descr =& patBBCode::createDescriber();
// create the driver
$driver =& $descr->createDriver( 'HTML' );
// tell the describer to use the driver
// $descr->setDriver( $driver );
// and display the documentation
echo $descr->describe( $BBCode );
You can view the result here - this is included in the examples collection of the package. For the moment, the HTML driver is very simple, but I intend to add a patTemplate driver which will give you total layout control. Another feature worth noting: the Describer respects the locale you set in the patBBCode object you describe
Friday, November 26. 2004
Today, Sebastian released the first public version of patForms. Here's what he wrote in his release announcement:
"Many were eagerly awaiting this moment, and this is it: patForms is out, It's only an alpha version, but that depends on the parts of patForms you will be using. In you don't know what our form abstraction class is or what it can do for you, have a look at the overview. Otherwise, download and test away! Just make sure you report any bugs you find via our patBugzilla."
So the next thing is to propose this package to PEAR as it would allow us a faster release cycle and provide a better infrastructure. And it would introduce this package to a broader audience.
If you haven't tried patForms yet, now's the perfect time for it.
In an entry in the Bitflux blog chregu writes, that they started integrating patForms in the Bitflux CMS.
So finally people start using this projects, which is great, as it hasn't even seen an official release yet. So if you wonder, how people can use this already, you may be interested in the latest CVS snapshot, API documentation or the examples.
I was really happy, that the guys at Bitflux like using patForms, as they developed a lot of things I really liked and chregu is one of the few people I really look up to, when it comes to XML knowledge.
The only feature they have been missing so far is multi-page support, but this is on my todo list, maybe I could work on this together with the Bitflux team.
This morning, Sebastian promised to prepare a first release and already applied for a PEAR account, as we would like to submit this project to PEAR (this has been requested by people like Toby, Lukas, Klaus, Arnaud, Carsten, Aaron, Markus and Christian). Hey, this should ensure our five votes, that we need...
So keep your eyes open for the first official patForms release, or get the latest snapshot, there are tons of (well documented) examples included, so it should not be too hard to get started with patForms. We are already using it in a lot of commercial projects, when will you start using it?
Tuesday, November 23. 2004
I just released the first public version of Services_Delicious, a PHP API for the REST based webservice of the social bookmarking site del.icio.us. If you've read my last blog entry on this topic, you already know, what it can do for you.
If you are not familiar with social bookmarking, here's an introduction for you:
Social bookmarking allows you to compile a list of categorized links that are accessible through a website by other users. This has the advantage that you can also browse the bookmarks of others and easily find interesting site. del.icio.us is a quite pouplar bookmarking site, which also offers a webservice to add new bookmarks or read your existing ones using HTTP and XML.
When using Services_Delicous you can easily manage your bookmarks using PHP: <?php
$dlc = &new Services_Delicious($username, $password);
$posts = $dlc->getRecentPosts('php', 10);
print_r($posts);
?>
Adding a new bookmark is not any harder:
<?php
$dlc = &new Services_Delicious($username, $password);
$result = $dlc->addPost('http://pear.php.net', 'PHP Extension and Application Repository', 'The home of Services_Delicious', array('php', 'pear'));
if (PEAR::isError($result)) {
die($result->getMessage());
} else {
echo "Success";
}
?>
Services_Delicious provides a lot of more methods, API documentation should show up on the PEAR website quite soon and I already started writing the end-user documentation for the PEAR manual.
Monday, November 22. 2004
Although my PEAR package Services_Ebay is still in devel state, I started writing documentation for it. So far I've finished the "Getting started" section which helps you setting up your developer account at the eBay developer program and gets you aquainted with the Auth&Auth procedures and the eBay sandbox.
These things got me stuck when I started working on the project and so I thought, I could attract more developers to the package by providing a shallow learning curve, as using Services_Ebay is a lot easier than understanding how the eBay webservice works.
I just committed the documentation the the PEAR website, but the manual is only rebuilt on Sunday, until then you may read it in my testing environment.
Sunday, November 21. 2004
Carsten (aka luckec), a friend of the pat-team has just relaunched his personal site tool-garage.de.
The site has been built with patPortal, a project of Sebastian, Carsten and myself. I'm also working on some other projects together with Carsten like Date_Holidays or ext/id3. His site now finally is in English and he has published some new projects, so please give it a try.
Thursday, November 11. 2004
In his last entry for the PHP Conference, Aaron made me personally responsible for the failure of the party on Tuesday.
He blames me for giving a private session on patForms at the hotel bar, but hey, there were only about six people watching it... I hope S&S will allow me to attend the conference next year nevertheless.
I've been talking to Sebastian this morning, and he would also like to see patForms in PEAR, so I guess I'll start a proposal on this as soon as I find some time for it. I'm already in pain when thinking of the work that has to be done to adjust the coding standards in all files....
Comme certains ont peut-être remarqué, j'ai déménagé d'allemagne pour retourner en france. J'en ai profité pour faire de mon blog perso un blog entièrement en français, sur lequel vous pourrez suivre l'actualité de pat sans avoir recours à vos talents de traducteurs en herbe.
(As some might have noticed, I have moved back from germany to france - if you want to try and put your translation talents to the test, you can now follow pat news in french via my own personal blog)
Wednesday, November 10. 2004
Indu Britto has put together a preview of the next issue of the PHP Magazine. This will feature an article written by me that introduces you to the possibilities of XML_Serializer. This will buy me some time on writing documentation, as I can point all people having questions to the article. Issue 01.2005 is scheduled to hit the stands on the 14th of December, 2004.
Monday, November 8. 2004
patForms is slowly reaching maturity, and for those of you who have been following patForm's development a little closer, there have recently been a few interesting changes:
- I have entirely rewritten the Date element, which now generates several input fields directly for each token in the specified date format, and can either display as several text input fields or select boxes. The API has changed a bit, so if you are using the Date element in your projets, be careful when upgrading. Please post any bugs you find via bugs.php-tools.net.
- I have reviewed all the patForms elements and rewritten parts to optimize the code, and finish implementing the display and edit attributes - they now work correctly in HTML and Readonly modes.
- Finally, I added a small feature to the examples framework, which is to display the submitted form values after submitting a form.
- Stephan on his side has finished implementing the Group element, and thanks to the new patForms_Collection class which can be used for handling multiple forms, the patForms_Parser can now handle multiple forms in a form template.
- Stephan also added support for external user error codes definitions so you can either define your own for the existing locales, or add new error codes for your own locales.
As it stands, we will release a first beta of patForms this month, along with an article in the international PHP Magazine on easy form management also featuring patForms. You can have a look at the current CVS snapshot via snaps.php-tools.net.
Sunday, November 7. 2004
While sitting in the excellent PEAR workshop held by Toby and Lukas, I released a new version of Services_Ebay. This version brings the ArrayAccess interface to the models.
That means, they can be used like you would use an array:
<?php
$item = $ebay->GetItem($itemId);
echo $item['Description'];
?>
You may read, write and delete properties using this syntax. I had the idea, while Toby and Lukas presented their small application, which combines Services_Ebay with QuickForm, MDB2, Auth, LiveUser as well as some other packages.
For some some coverage of the workshop take a look at the excellent posting by Aaron Wormus.
Saturday, November 6. 2004
Tomorrow morning I'll be leavin for the International PHP Conference 2004 in Frankfurt.
I'll be doing two talks:
- SessionServer - Maintaining state between different servers
- The big documentation extravaganza
The first talk will focus on one of my PEAR packages, HTTP_SessionServer, which provides a simple daemon that is able to store key/value pairs on a remote server. It comes with some PHP functions that you can register with session_set_save_handler().
My second presentation will not contain any code, but is a short trip through the land of documentation tools. It will showcase tools like phpDocumentor, DoxyGen, reST and DocBook.
I'm also looking forward to attending a lot of other sessions. On Sunday, Lukas and Toby will be giving a 6 hours workshop on PEAR, where they will be using my Services_Ebay package in combination with MDB2, Quickform and a bunch of other packages. Furthermore I plan to attend Chregu's XML-talks as well as Volker's talks on XUL and SOAP. You can find a timetable of all sessions on the conference website
The International PHP Magazine has set up a conference-blog and all speakers will be able to post their thoughts there, so you probably should bookmark their site to get all the latest information.
|