MARCH 2003 php|architect VOLUME II - ISSUE The Magazine For PHP Professionals Exploring XSLT Processing Options Within PHP Turn XML into HTML with various proven methods Beauty and Brains: Using Flash's ActionScript, XML and PHP for Easy Multi-tier Solutions www.phparch.com Blazing Site Performance Using Objects and Sessions Creating an RSS Client With PHP FreeTrade: A PHP-Based E-Commerce Solution Plus: Tips&Tricks, Book Reviews, Product Reviews and much more Web-Free PHP: Using PHP's CLI Interpreter Introducing the php|architect Grant Program As PHP’s importance grows on the IT scene—something that is happening every day—it’s clear that its true capabilities go well beyond what it’s being used for today The PHP platform itself has a lot of potential as a general-purpose language, and not just a scripting tool; just its basic extensions, even discounting repositories like PEAR and PECL, provide a highquality array of functionality that most of its commercial competitors can’t afford without expensive external components At php|a, we’ve always felt that our mission is not limited to try our best to provide the PHP community with a publication of the highest possible quality We think that our role is also that of reinvesting in the community that we serve in a way that leads to tangible results To that end, this month we’re launching the php|architect Grant Program, a new initiative that will see us award two $1,000 (US) grants to PHP-related projects at the end of June Participating to the program is easy We invite all the leaders of PHP projects to register with our website at http://www.phparch.com/grant and submit their applications for a grant Our goal is to provide a financial incentive to those projects that, in our opinion, have the opportunity to revolutionize PHP and its position in the IT world In order to be eligible for the Grant Program, a project must be strictly related to PHP, but not necessarily written in PHP For example, a new PHP extension written in C, or a new program in any language that lends itself to using PHP in new and interesting ways would also be acceptable The only other important restriction is that the project must be released under either the LGPL, the GPL or the PHP/Zend license Thus, commercial products are not eligible Submit Your Project Today! Visit http://www.phparch.com/grant for more information TABLE OF CONTENT php|architect Departments Features INDEX 12 EDITORIAL RANTS NEW STUFF Shell Scripting with PHP (PHP CLI) by Jayesh Jain 19 FreeTrade, e-commerce for developers by Vladan Zirojevic REVIEW TUTOS 32 29 REVIEW Blazing Site Performance Using Objects and Sessions by Peter Moulding phpLens 67 TIPS & TRICKS 41 Writing an RSS Aggregator With PHP by Marco Tabini 49 Exploring XSLT Processing Options Within PHP by John Holmes 70 BOOK REVIEWS PHP Professional Projects Professional PHP Web Services by Stuart Herbert 72 exit(0); Let Me Throw The First Stone 58 The Story of theBouncing Ball and XML by Sam Smith March 2003 · PHP Architect · www.phparch.com The designers of PHP offer you the full spectrum of PHP solutions Serve More With Less Zend Performance Suite Reliable Performance Management for PHP Visit www.zend.com for evaluation version and ROI calculator Technologies Ltd EDITORIAL RANTS EDITORIAL Awwww Yeah These were the first words I uttered after accepting an invitation to take the reins as editor-in-chief for php|architect magazine About weeks later, Marco, our fearless publisher, reminded me that I still had to write the ‘Editor’s Rants’ aritcle This is essentially what you see at the beginning of seemingly every magazine ever published ‘Letter from the Editor’, ‘From the Editor’s Desk’ Whatever you want to call it – it’s all the same – and as far as I can tell, it’s all pretty meaningless Over the past few weeks I’ve read no fewer than 30 of these articles, trying to get a clue as to this article’s purpose in life I read magazines covering every conceivable topic, formal and informal, from the politically perfect to the underground, grass-roots publications and found that these editorial columns all seem to accomplish a single goal: to make the editor look like the most pretentious, micro-managing, self-important species ever to roam the earth Did these people lack attention as children or something? The more I read, the more I came under the suspicion that the species I had been recruited to emulate might be well not my cup of tea I also couldn’t help but ask myself out loud on several occasions, ‘who reads these things?’ But alas, this is not meant to be an editorial on editorials (or a ‘metatorial’ if you will) If I’m forced to partake in this charade, then I will endeavor to make it something useful It so happens that, being my first month at the helm, I have plenty to share with whoever is reading this, specifically with regard to my vision for php|a over the coming months I welcome comments on all of this, by the way: brian@phparch.com I’ll break my thoughts down into sections covering our current status, the near future, and the longer haul Where We Are From rather humble beginnings, I think php|a has accomplished much with regard to the vision of its creator – Marco Tabini This vision was twofold, so I’ll cover them seperately First, php|architect has become known as a reputable resource for well written, well edited documentation covering all aspects of PHP development While I will not bore you with the laborious details of how challenging it can be to combine March 2003 · PHP Architect · www.phparch.com php|architect Volume II - Issue March, 2003 Publisher Marco Tabini Editor-in-Chief Brian K Jones brian@phparch.com Editorial Team Arbi Arzoumani Brian Jones Peter James Marco Tabini Graphics & Layout Arbi Arzoumani Administration Emanuela Corso Authors Stuart Herbert, Jayesh Jain, Peter Moulding, Dave Palmer, Sam Smith, Marco Tabini, Vladan Zirojevic php|architect (ISSN 1705-1142) is published twelve times a year by Marco Tabini & Associates, Inc., P.O Box 3342, Markham, ON L3R 6G6, Canada Although all possible care has been placed in assuring the accuracy of the contents of this magazine, including all associated source code, listings and figures, the publisher assumes no responsibilities with regards of use of the information contained herein or in all associated material Contact Information: General mailbox: Editorial: Subscriptions: Sales & advertising: Technical support: info@phparch.com editors@phparch.com subs@phparch.com sales@phparch.com support@phparch.com Copyright © 2002-2003 Marco Tabini & Associates, Inc — All Rights Reserved EDITORIAL editorial precision with technical savvy, I will say that this process and this accomplishment both fall under the heading of ‘non-trivial’ tasks Certainly a very large thank you is in order for each of the many authors who collaborate with our editorial staff each month Working together, we have been able to overcome challenges ranging from differences in opinion to differences in time zone, culture, and even language Their time, patience, and hard work is very much appreciated Second, php|architect continues to make great strides in establishing itself as a voice for the PHP developer community, as well as an advocate for the deployment, evolution, and progress of the PHP platform We haven’t sought to glorify the state of PHP, nor to shun its more proprietary peers Instead, we try to maintain a realistic focus on the use of PHP in production environments We also take a decidedly optimistic view of the future of PHP, which at times finds itself at odds with what some of the larger names in community might have in mind Nevertheless, we feel that the opinions of our authors, the editors, and the community are an important part in shaping any project which lists ‘open development’ as a goal The Months Ahead The months ahead will continue to build upon the foundation laid in the first months of our existence The main goals in the immediate future focus largely on quality and efficiency – in other words, bringing you even better quality content whithout breaking our necks or collapsing from exhaustion in the process To that end, there have already been improvements, tweaks and hacks put in place First, we’ve convinced a one-time volunteer editor, Peter James, to come on staff as a full-fledged editor Peter has proven himself to be a tireless worker and a great collaborator He has already done wonderful work here, and he will undoubtedly leave an indelible mark upon the pages of php|architect over the coming months Second, as further proof of our commitment to the community at large, we are very proud to announce this month the launch of a grant program to aid fledgling (or not-so-fledgling) projects to continue to progress and bring PHP into the places where no man has gone before – or at least the road less traveled See this months pages and March 2003 · PHP Architect · www.phparch.com the php|architect website for more details The Longer Term Looking out and attempting to predict our future at such an early stage, while fun, is probably also an exercise in futility All that can be said for sure is that there are plans of great size and great number More huge ideas are born every day Surprisingly, only some of the ideas belong to us ‘staffers’ The rest come from you! So far, most of the changes and adjustments we’ve made, and some which we’re working on, have come directly from our readers We’re all constantly monitoring emails, looking in the php|architect forums, and even monitoring the PHP mailing lists in search of yet another unfulfilled need that we might be able to lend a hand to Please keep these requests coming! There is hardly a greater compliment that can be paid to a publication than constructive feedback In Conclusion So now that I’ve firmly planted the image in your head of an SUV-driving, tie-wearing, cleanshaven, pretty boy editor sitting in his overstuffed couch with a $4.00 cup of coffee and a laptop, let me assure you that while I take the publication and my work seriously, I don’t take myself all that seriously at all The reality is that I have hardly a clue how I got here I can only be thankful for Marco’s obvious and complete insanity in choosing me for this post I am grateful both to Marco for this opportunity, those authors with whom I’ve had (and continue to have) the distinct honor of collaborating, and the many readers who have offered their feedback and encouragement Until next month NEW STUFF NEW STUFF PHP 4.3.1 Released The PHP Group has announced the release of version 4.3.1 of the PHP interpreter The new release addresses a bug in the CGI version of the interpreter that invalidates the effectiveness of the —enable-force-cgi-redirect compile-time switch This, in turn, makes PHP-CGI susceptible to outside hacking attacks that could result in the execution of arbitrary PHP code For more information, visit http://ca.php.net/release_4_3_1.php ADODB 3.20 Available A new version of ADODB, the popular and efficient database abstraction library, has been released by its maintainer, PHPEverywhere blog author John Lim ADODB 3.20 supports several new features, including abstracted capabilities for creating tables and indexes, although this functionality is still considered in its alpha stage According to its website, available at http://php.weblogs.com/adodb, ADODB is twice as fast as PEAR-DB and 10% faster than PHP-Lib new features, such as CVS integration, advanced project management capabilities and improved performance on all platforms The Zend Studio 2.6 is priced starting at $195 (US) More information is available from the Zend website at http://www.zend.com Introducing the php|architect Affiliate Program Earlier this month, we proudly announced the introduction of our new affiliate program, which pays a commission for each purchase made through our website by visitors referred from on of our partners Participation in the program is free, and open to all websites, without any minimum requirements You can find more information on the php|a website at https://www.phparch.com/afflogin.php PHP Conference in Montréal Nova: A P2P Client In PHP The Nova Project has released Nova, a peer-topeer application compatible with the popular GNUtella file-sharing network Nova is written entirely in PHP using the PHP-GTK extension, and provides an excellent example of how PHP can be used to develop application outside the Web space Nova, which is based on the GnucDNA library, currently supports only basic functionality and is only compatible with Windows You can find more information at the project’s homepage (https://sourceforge.net/projects/novap2p/) PHP Québec will hold their first PHP conference in the city of Montréal on March 20 and 21 Speakers at the event include a who’s who of the PHP community, including Zeev Suraski, Andrei Zmeivski and Rasmus Lerdorf php|architect will also be there and our own Marco Tabini will give a presentation on PHP-based business and our experience in the world of electronic publishing For more information, you can visit the conference’s web site at http://phpconf.phpquebec.com/ Zend Releases Studio 2.6 PHP powerhouse Zend Technologies has release version 2.6 of their Zend Studio IDE The new application includes several bug fixes, as well as March 2003 · PHP Architect · www.phparch.com php|a REVIEWS Reviewed For You TUTOS REVIEW The Ultimate Team Organization Software By Marco Tabini A few days before writing this review (which, at the time, was another review), I had something of an epiphany I was on the phone with a client, boasting about how organized I am, when Arbi walked by my office and laughed a typical “I know better” at me My ego was bruised, so I wrote down a list of ways that I am organized on a piece of paper I’d gladly show you that piece of paper if I hadn’t, er, temporarily misplaced it As the saying goes, if you can’t blame anyone but yourself, blame the process After all, a person can only so much on his own I set out to find a decent groupware application that would allow me to get more organized and, at the same time, better manage the office’s internal processes (formatting Arbi’s hard drive would have been a bonus, but I couldn’t find any applications capable of the perfect union between a calendar and that) After a bit of searching, I came across TUTOS, which stands for The Ultimate Team Organization Software Created by German developer Gero Kohnert as an internal application for his previous employer, TUTOS has evolved into a complex groupware application that is used by the likes of Siemens Best of all, it’s written entirely in PHP March 2003 · PHP Architect · www.phparch.com The Cost: Free (released under the GPL) Requirements: Apache You wil need one of these Databases PostgreSQL Database MySQL Database (MySQL-3.23.21-1.i386.rpm) Oracle Database Borland Interbase PHP (minimum php4.1) Download Page: http://www.tutos.org/homepage/download.html Home Page: http://www.tutos.org Developer Background: “I started a first TUTOS like system for my former company back in 1997 or so They still use it alot to have an overview of all their customers , software installations and different products and to support the internal Quality Managment (ISO9600) After leaving this company I started TUTOS, an enhanced system based on the same thoughts with a lot more features On TUTOS I'm working now for more than a year and after making a first installation in my department at my current employer I think it is time to release it to the public, giving something back to the Open Source Community.” REVIEWS TUTOS Groupware, Anyone? TUTOS is a complete groupware application in every sense It includes a calendar, a contact management system, a bug tracking system, a product/project repository, mail capabilities, a time tracking system, an invoicing system, and much more The system is also multilingual, supporting about fifteen languages right out of the proverbial box For companies whose groups work in different parts of the world, TUTOS includes the ability to specify timezone information for each user profile, so that everything remains properly synchronized and meaningful to all users Finally, the system includes a “watchlist” mechanism that makes it possible to remain up-to-date, via e-mail, on changes to systems such as the bug tracking database or the calendar schedule Even for a small workgroup, this “active notification” approach is a very important feature, particularly when the members of a team not all work in the same office User Interface and Security Features The system implements a very fine-grained permission system, thus ensuring that the administrators have every way to control access to each function In addition, a TUTOS administrator has prompt access to all of the security settings, including his/her own TUTOS features a colourful and easy-to-use interface that is sure to please both lovers and haters of GUIs As Figure March 2003 · PHP Architect · www.phparch.com REVIEWS TUTOS Figure you can see in Figure 1, only a minimal amount of information is kept on the left-side frame menu, leaving as much real estate as possible available for the system’s actual functionality TUTOS doesn't use any proprietary components that are tied to a particular architecture Documentation, Interoperability and Limitations It’s interesting to notice that the ultimate goal of the TUTOS project is to create a portable groupware system whose interface can be written for a number of different platforms As such, the development team has put a large amount of work into the design of the underlying data structures themselves Naturally, that’s good news because, in addition to the PHP interface, other interfaces are likely to be developed In fact, a KDE/Gnome version is currently in the works From a portability perspective, TUTOS’ PHP interface doesn’t use any proprietary components that are tied to a particular architecture, and it supports several different database systems, including MySQL, PostgreSQL and Oracle In my opinion, the system could use a bit more work as far as interoperability is concerned In particular, I March 2003 · PHP Architect · www.phparch.com think that attention should be paid to integration with outside services like LDAP and/or Microsoft Exchange This could help make TUTOS a more appealing solution for larger organizations Since the entire system is based on PHP, however, it should be relatively simple to expand its functionality to include whatever elements one needs The code is quite clean and well documented, so it forms a good foundation on which to build a more complex and specialized application TUTOS includes a good deal of documentation For the developer, the TUTOS website provides a detailed analysis of all the data structures and logical organization of the system, as well as an API reference and an installation guide As for the end user, they get a complete contextual help system, shown in Figure 2, that includes an accurate description of what each individual screen does Conclusion Now that I have TUTOS running on my computer, I can say with confidence that I feel more organized As with all groupware systems, the trick to getting TUTOS into an organization is to stimulate user acceptance After all, your average user is normally not keen on trying new things, and prefers instead to stick with the application that he or she has learned to use well TUTOS represents an excellent groupware solution that is easy to learn and offers a wide array of functionality It is organized in a logical fashion, provides lots of documentation, and its PHP codebase makes it easily extensible php|a 10 ... by Peter Moulding phpLens 67 TIPS & TRICKS 41 Writing an RSS Aggregator With PHP by Marco Tabini 49 Exploring XSLT Processing Options Within PHP by John Holmes 70 BOOK REVIEWS PHP Professional... Subscriptions: Sales & advertising: Technical support: info@phparch.com editors@phparch.com subs@phparch.com sales@phparch.com support@phparch.com Copyright © 2002-2003 Marco Tabini & Associates,... requirements You can find more information on the php| a website at https://www.phparch.com/afflogin .php PHP Conference in Montréal Nova: A P2P Client In PHP The Nova Project has released Nova, a peer-topeer