PHP 5 Trends in 2004
PHP 5 Beta 4
And given that the PHP 5 upgrade was also for OOP-Object Oriented programming purity, the prospects were ... too close to a possible perversion. Imagine my pleasant surprise when I discovered the new PHP 5 is chock full of useful new functionality and well designed extensions. And the new stuff does not break the old except in some clear cases of object usage. However the new SimpleXML and libxml2 based functions are so good they may very rapidly displace old coding practices in the XML arena. And the ability of PHP 5 to act as a command line utility right out of the download is such a godzend - you can clearly see that this preliminary reviewer is delighted with the PHP 5 upgrade path to date. Take a look at what the PHP 5 beta has to offer and decide for yourself.
the most interesting development from a usage point of view in PHP 5 is that
the program can be used in the CLI-Command Line Interpreter mode right off
the download and compile(or download and install if using the executable
binary). Before users had to make changes to php.ini file and/or switch executables and
.DLLs in Windows. Regardless of platform, getting into command line mode
was a nuisance. No Longer - as can be seen from the figure below.
The primary aim of this version of PHP was to fix the OO infrastructure from a somewhat kludgy runtime implementation and at the same time to broaden the OO infrastructure while adding modern try/catch exception handling constructs. But as usual the Zend/PHP folk have added a whole bunch of extra goodies to the PHP function libraries not the least of which are libxml2 support, a new SimpleXML syntax model which is going to be quite influential, and SQLite support which adds a new very lite, but complete SQL database to the mi x. And we have not even mentioned some of the other goodies. So without further to do lets see what's new in PHP 5.
What's New in PHP 5
One of the advantages of scripting languages like PHP is that they are easy
to code in and test because o their fast, interpreted turnaround. PHP with its
new out-of-the-box interpreted CLI-Command Line Interface reinforces that ease
of use. But the scheduled fixes to the OO mechanism had some PHPers worried that
PHP would become so much more complex to code in. Not to worry. the OOP extensions
do not impose an inheritance hierarchy on coders like Java and really do put
PHP on a much more solid OOP footing. Here are some of the notable OOP improvements.
The next area where PHP has generally shored up its processing capabilities is in error handling. This is where the new OO functionality comes into play. First, PHP 5 supports three new keywords try, catch, throws which works just like in Java or the languages copying from Java like C# and Visual Basic. This upgrade puts error handling in PHP on a systematic basis so that coders are less likely to see all sorts of different error handling schemes and routines. Also, because exceptions are OO based, users can more readily customize exception handling routines by inheriting from the standard exceptions to write derivative exception classes that explicitly meet their needs while staying within a familiar exception handling framework. The downside to exception handling is that now unhandled exceptions are fatal - they cause PHP's runtime to come to a halt. Partially, this reflects the status quo; but there is a wider range of exceptions that must be handled or else.
Some Really Good Goodies
The bulk of the improvements to PHP were targeted to put it on a better standard for Object Oriented programming and exception handling. The proposed changes in PHP 5 appear to be well directed to achieve these ends. However there are some goodies in this update too. First there are the performance improvements. The new OO code runs faster, so does the new onboard database, SQLite, in single-user operations. Finally, a new memory manager has been added which streamlines memory handling in multi-threaded tasks. We have yet to do benchmarks as we await the final code. However, in standalone, single user tests we have seen the new SQLite standard database outperform MySQL and PosgreSQL; so the runtime performance indicators are positive.
But there can be no doubt one of the real goodies of the new PHP 5 is the
adoption of the fast libxml2 code to support XML and XSLT parsing plus the
adoption of SimpleXML. The latter is a brilliant simplification. After defining
the root node, SimpleXML parses the XML into a tree in which each
XML tag is just an object property whose contents are accessible in the normal
PHP way. A bit of sample code will give the flavor:
title=States want Microsoft licensing improved
We found in PHP beta3 that SimpleXML routines tended to flounder on complex XML such as XSD schema files or complex XML file formats with namespaces, etc. Beta 4 promises improvements which we shall report on at a future date. Nonetheless, this simplification in XML parsing really throws down the gauntlet to other developer tools to make improvements in their languages that match this for the ever more important XML processing that is confronting developers everywhere.
And there are still more goodies. One that this developer really likes is the inclusion of SQLite with PHP 5. SQLite implements more of the SQL 92 standard than MySQL including triggers, subselects, and most joins. However, SQLite is exactly that - a single file database with very simple locking mechanisms (all inserts, updates, deletes lock the entire database), one level commit and rollback procedures, no smart caching, and no user partitioned files or tablespaces. Buts this simplicity is not misplaced in the world of data processing. For single user or read-only databases, this is a splendid vehicle because its SQL is quite robust and its performance is very reliable and very fast. So think of SQLite as solving a whole range of persistence problems associated with your systems that flat files quickly run out of steam for and XML is too verbose and/or does not have the querying finesse to handle. When requirements are multi-user or heavy transaction switch to the appropriate MySQL, Oracle, PostgreSQL, or other heavyweight database. Use the free ADO.lib drivers for SQLite and that switch is made even simpler.
And there are even more goodies in PHP 5. The addition of a Reflection API and the instanceof keyword will be welcomed by MDA developers who want to use models to drive the development and generation of basic IT architectures and the resulting backbone code for major middleware and support systems. Lots of new coding tools will have this type of wizard or generation component that can also take advantage of a more robust Object model in PHP 5. In addition there are simplifications to streams and basic transport mechanisms including the ability to access low-level socket operations on streams. Finally, there are a number of small improvements in a number of library functions - some are bug fixes and other are simple extensions. The result is a better PHP environ to develop with.
Lets not be coy. All in all we think that this upgrade to PHP is so good that it will give PHP a huge groundswell of increased popularity. The reason is simple. You can still hack easily in PHP 5; but now you can also adopt design rigor where required to add highly portable functionality through OO classes. Performance is improved and with Zend's new WinEnabler FastCGI, Windows PHP code runs as fast as and as stable as on Linux. It also helps that out of the box PHP is command line usable. This will create a secondary community of cross platform PHP apps that do all sorts of useful system administrative chores that can be run live or from a browser. The SimpleXML and incorporation of libxml2 could not be timed more brilliantly. With the succession of OpenOffice and Office 2003 using XML as storage format, the emergence of native XML databases, and the more frequent use of Web Services and the imminent release of Macromedia Flex using MXML and Adobe's XML-based XDP plus the wild popularity of RSS-feeds and Weblogs - being able to handle XML as straight forwardly as in in SimpleXML and with the speed of libxml2 is going to be very attractive to a lot of developers. Also, if used appropriately (think single user and/or primarily read-only databases) SQLite is also going to make providing of persistence aids such as saving a users different desktop workspaces much more practical. Finally, there are the blitz of new PHP5 object libraries that are sure to surface in the next year or two. PIMP, a photo processing library par un Francais qui sait Anglais tres bien telque il choisit le nom de "PIMP" avec un sourire mechant. PIMP is impressive as its methods can be called either in classic PHP functional form or using OO syntax. Those routines allow users to draw 2-1000 times faster than GD; do sophisticated image blends and color adjustments; do vector and font graphics with antialiasing; do filtering with a choice of dozens of effects and the ability to add plugin libraries. With this class library expect to see a flood of smart photo albums that allow end users to correct, annotate , and make "salescards" or calendars for online email or offline printing. Expect to see mapmakers unite maps with images of local business or sites to see. Expect to see online sales catalogs customized to the size and styling of product images and info pitch that each customer wants
. In sum, without even trying hard, PHP 5 beta 4 already suggest
so many possibilities only a huge performance drop and/or buggy gaffe could
do in PHP 5 now. The lack of an IDE with drag and drop visual layout of forms
and reports is another possible factor keeping PHP 5 from being one of the
biggest developer debuts in a year which will be filled
Top of Page Tutorials Home PHP References and Links