Started just over ten years ago, the PHP programming language has become the most popular programming language for web application development. PHP 5, the most recent release, adds even more features — all the while remaining approachable to novices. But don’t let the friendly facade fool you — Fortune 500 companies are taking notice, too. Here’s a look at the life of PHP 5 so far.
A little over ten years ago this past June, Rasmus Lerdorf posted a message to Usenet group comp.infosystems.www.authoring.cgi titled “Announce: Personal Home Page Tools (PHP Tools). ” His message, announcing the release of PHP 1.0, highlighted a number of language features that, for the time, were in great demand: the ability to log traffic, process form data, and display “last access” timestamps on web pages, all of which were nothing short of black magic to web developers that were enthusiatic but plagued with a lack of tools to turn their ideas into reality. Rasmus concluded his post with a note that PHP was being released under the GNU Public License, further punctuating the point by exclaiming, “Yes, that means[ it’s] free! ” 20,478,788 users later (according to Netcraft.com), the rest is history.
Confirming Rasmus’ suspicion that if he found such tools useful, others might too, his decision to release the software under an open source license prompted a slew of language contributions, and a team of developers soon assembled to spearhead the language’s further evolution and maturation. The outcome is a model example of how an open source project can truly thrive. For what started out as a personal project by a software development contractor interested in monitoring access to his online resume, PHP has since become the most popular web scripting language in the world, used by hobbyists and Fortune 500 corporations alike.
As PHP’s user community has grown, so has its capabilities, with the latest release, PHP 5.0, offering over 140 libraries totalling well over 1,000 functions capable of handling an impressive array of tasks, including database and e-commerce integration, complex date, string, and file manipulation, and XML parsing and transformation. Another 117 extensions are available in the PECL PHP Extensions repository (http://pecl.php.net/), and still several hundred more packages that extend the language available at the PHP Extension and Application Repository (better known as PEAR, located online at http://pear.php.net/). Of course, this doesn’t take into account the countless third-party applications made available through disparate web sites, nor the 11,122 PHP-driven projects managed through Sourceforge.net (http://www.sourceforge.net/).
Even ten years after the 1.0 release, community activity is nothing short of extraordinary. The most recent telling evidence of the language’s continued success is the July 2004 release of PHP 5.0.
The Coming of PHP 5.0
In development for several years, the PHP 5.0 release represents a major milestone in the history of PHP. Not only does the release improve upon numerous existing features, but it also incluces a bevy of new capabilities. Some of the most significant enhancements include:
*Revamped Object-Oriented Programming model. Easily the most eagerly awaited, not to mention controversial (more about this later) language enhancement is PHP 5’s object-oriented programming (OOP) support. While still not fully object-oriented (at least according to the traditional definition), there’s little question the changes made to version 5 dramatically improve upon prior capabilities. The object model has been completely rewritten, resulting in significantly better performance. Class members and methods can now be declared as private, protected, and static. Furthermore, methods can also be declared as abstract and final. PHP 5 also standardizes class constructors and destructors and provides contractual enforcement of class implementation by way of interfaces.
*Exception handling. PHP 5 now supports an exception handling model similar to that found in Java and C++. It’s also possible to nest exceptions, as well as extend the default Exception class.
*Enhanced XML and Web Services support. Like its object-oriented support, PHP’s XML capabilities are overhauled in version 5. For starters, all XML-related extensions now depend upon the libxml2 library (http://www.xmlsoft.org/). XML support is further enhanced with the addition of the SimpleXML extension, which offers a rather compelling means for manipulating XML using an object model. Finally, in response to the popularity of third-party SOAP extensions, a native SOAP extension is incorporated into the new release.
*A new MySQL extension for MySQL 4.1+. PHP’s MySQL extension is a critical part of countless web applications around the world, connecting PHP applications to the popular open source database. In PHP 5, the MySQL Improved (or mysqli) extension updates the original extension, incorporating innumerable changes to take full advantage of the new features of MySQL 4.1. (The older MySQL extension continues to work, albeit with older versions of the database software.) In addition to offering both a procedural and object-oriented interface, the new extension supports a range of connection, security, and functional features — such as greater support for transactions, and new support for replication, load balancing, and debugging — that were not available in the original extension.
*Support for SQLite. While open source databases like MySQL and PostgreSQL offer budget-conscious developers a powerful solution, both packages require a fair amount of knowledge and maintenance overhead to operate effectively, not to mention that each database’s features far outpace the needs of many users, who in most cases are simply searching for a simple and effective means to store and manage data. To accommodate “simpler” needs, PHP 5 is bundled with an extension for the SQLite embeddable database engine (http://www.sqlite.org/). SQLite is a relatively tiny database engine consisting of less than 30,000 lines of C code, yet capable of supporting databases of up to two terabytes in size. The databases are file-based, and use the operating system’s privilege system to determine read and write access, rendering administration a trivial matter for both backups and user management.
Of course, no major language release is complete without at least a little bit of contention and drama. Most notably, the decisions to improve PHP 4’s questionable object-oriented capabilities, coupled with the unbundling of the MySQL extension wrought a fair amount of confusion, not to mention hackles, across the user community.
The Contentious Java Clone Conspiracy
Like most successful open source projects, the march forward is often accompanied by no small amount of debate. A case in point: the decision to incorporate additional object-oriented capabilities into the PHP 5 release.
While few would dispute the inherent advantages of an object-oriented programming model over procedural coding, the enormous success of PHP in its early years seemed to spawn a belief in some circles that proferring substantial object-oriented features would somehow detract from the language’s perceived “friendliness” and “simplicity,” something that greatly appealed to individuals with no prior programming experience. A December 2003 Usenet perhaps best sums up the controversy:
If you like OOP, you’ll probably get a kick out of the new object model. If you understand OOP, you will still be wondering how much sense OOP makes without strong typing. If you don’t like OOP, it’ll be a huge disappointment:[a]slightly larger system footprint, but no additional functionality; just another step along the way of turning PHP into a Java clone.
That sentiment wasn’t uncommon. In the months leading up to the release, there were several contentious debates regarding this decision on various newsgroups and strong opinions voiced on blogs and in other online resources. Of course, it soon became clear to most that the developers’ intentions wasn’t to create a Java clone, but rather to frame common OOP capabilities in the spirit of PHP’s long-standing features.
For most developers, this matter has largely become moot. If you want to program with procedures, you can. However, if you want to program with objects, PHP 5’s OOP features are far more powerful than what was available in any of the preceding versions.
Unbundling the MySQL Extension
It’s no secret that both the PHP and MySQL communities have long benefitted from each other. In fact, it’s arguable that neither project would have ever reached anywhere near their present levels of popularity had the reciprocal relationship not been established with the addition of MySQL support in PHP 3.0b3, which was released on January 17, 1998. Since then, developers of the respective projects have actively promoted the benefits of using PHP and MySQL to power web sites both large and small.
Indeed, even more than seven years after the first MySQL extension was bundled with PHP, both communities remain quite cognizant of the impact of the symbiotic relationship. And perhaps this is no more apparent than in the chaos that ensued when the PHP developers unbundled the MySQL extension from the PHP 5 distribution, forcing users to manually enable it should they wish to use PHP and MySQL together. While for a time there seemed to be no end to the speculation as to why this was done, the decision ultimately boiled down to a simple licensing conflict.
From its very first public release back in 1996, MySQL had long been licensed under the Lesser GNU General Public License (LGPL). Meanwhile, PHP has always been licensed under the PHP License, an Apache License variant that’s compatible with the LGPL terms. However, with the formation of MySQL AB (http://www.mysql.com/), the company founded by MySQL’s core developers to offer an array of MySQL-based products and services, some open source, some commercial, the MySQL code was re-licensed under the more restrictive GPL. While adopting the GPL still permits open source developers to use MySQL for free and allows MySQL AB to charge for products — goals consistent with the intentions of MySQL AB’s incorporation — GPL code cannot be used in conjunction with code falling under alternative licenses. The implication? The MySQL extension had to be unbundled from PHP 5, because the MySQL extension was essentially a bridge that integrated the two as a single entity.
To be sure, this decision caused no small amount of concern among relatively new users not aware of the licensing conflict, not to mention those who had been using PHP and MySQL together for so long. Indeed, the outcry was so great that it wasn’t long before MySQL AB was forced to ponder a solution. The compromise? Release MySQL under a third license, known as the FLOSS, or Free/Libre and Open Source Software Exception (http://www.mysql.com/company/legal/licensing/foss-exception.html). This exception was created to permit use of the MySQL client libraries in conjunction with applications licensed under a variety of open source licenses not compatible with version 2 of the GPL.
While the resolution hasn’t prompted a rebundling of the MySQL extension in subsequent releases of PHP, and likely never will, it does allow for these two technologies to once again be used together in most cases without violating licenses.
Adoption Among Hosting Providers
PHP has long been supported en masse by web hosting providers; in fact, it seems almost an oddity when you encounter a web hosting provider that eschews PHP. However, given the wide range of client applications that are likely to be found at a hosting provider, upgrading to the latest version of PHP can often be a relatively slow process.
To determine just how far PHP 5 has penetrated into the ISP environment, several of the largest Web hosting providers in the United States were contacted and asked which versions of PHP were officially supported. Table One shows the results. The results are somewhat surprising, with relatively few hosting companies supporting PHP 5.
However, hosting companies typically adopt a new technology only when their customers demand it. Rackspace Director of Corporate Communications Annalie Drusch seems to confirm this suspicion in, stating “A handful of customers are asking for PHP 5, but most of them are interested in just playing with it. If any customers asks[ for PHP 5], we load it for them.”
Of course, as web services-driven applications continue to garner a larger share of developer’s attention, not to mention the features offered by MySQL versions 4 and greater, it’s fair to say client demands to upgrade to PHP 5 will only grow in the coming months.
Not surprisingly, PHP 5 support among several of the most popular open source PHP applications is strong. All of the applications listed in Table Two are compatible with PHP 5.
Interestingly, those applications that officially support PHP 5 were apparently able to do so with minimal effort. For instance, the most popular Web-based MySQL manager, phpMyAdmin, (http://www.phpmyadmin.net/) has supported PHP 5 since the earliest alpha release, with acknowledgement of support coming as early as May of 2003, more than a year prior to the official PHP 5 release. phpMyaAdmin also officially supported the new PHP 5 mysqli extension since April 8, 2004, more than two months prior to the official PHP 5 release.
Serendipity (also called “s9y” and available at http://www.s9y.org/) project founder Jannis Hermanns doesn’t recall any PHP 5-specific design decisions, saying “It just turned out that there was no incompatible code used. Even though no dedicated testing or analysis has been made made, we have[ yet to find] any oddities using s9y with PHP 5. For example, the web site http://www.supersized.org is using PHP 5 to serve 600+ blogs (including http://blog.s9y.org) and I have not noticed s9y+ php5-hickups[ sic]. ”
The Mambo (http://www.mamboserver.com/) developers also report minimal issues upgrading Mambo to support PHP version 5. In fact, the decision to do so was accidental. Asked about the events leading to the decision, core developer Mitch Pirtle responded, “[ It was] accidental. I ended up having a new laptop, and put PHP 5 on it for giggles, and discovered Mambo worked. So I mentioned it to the other developers, and saw similar posts on the forums, and more stringent testing began. One release later we were confident that Mambo ran happily on PHP 5 servers.”
Although the ubiquitous bulletin board solution phpBB (http://www.phpbb.com/) doesn’t officially support PHP 5 due to its use of the HTTP_*_VARS arrays (which have been deprecated in the more recent PHP release), phpBB is known to work with PHP 5 just the same. Asked about the present status, phpBB development team leader Meik Sievertsen responded, “The [phpBB]2.0.x line was developed at a time where we had a similar situation, but with PHP 3/4. Therefore, I don’t think we will officially stamp the PHP 5 label on[ phpBB version 2] until maybe after releasing “Olympus,”[ the forthcoming phpBB version 3 release.] ”
Of course, phpBB’s enormous installed base requires a rather disciplined approach to changing the packages mininum software requirements. Sievertsen affirms this, adding “If you serve such a large user base with so many different configurations, you have to set your minimum requirements very strictly. For phpBB3,[ you’ll need] PHP 4.1.0 or greater. We chose 4.1.0 because it seems to be still installed on a bunch of systems, including hosting providers.”
The OSCommerce (http://www.oscommerce.com/) team is also well on their way to PHP 5 compatibility. Project leader Harald Ponce de Leon responded, “Our next project milestone release (osCommerce 2.2 Milestone 3) will indeed be PHP 5 compatible, and will take advantage of what PHP 5 offers when the milestone path has been finalized.”
Also very aware of the needs of users running PHP 4, de Leon continues, “However, we do not plan to break compatibility with PHP 4 until PHP 5 has reached the market share that PHP 4 has reached. We plan on starting to take advantage of what PHP 5 offers by offering two versions of the classes we use, where one version is optimized for PHP 5 and can be used when PHP 5 is available on the server. This does mean the maintenance of the classes are doubled; however, we are then ready to drop PHP 4 support when widespread use of PHP 5 is available.”
If you’ve attended any of the recent open source conferences offered in the United States, you’ve no doubt seen a marked, significant shift in corporate adoption of PHP. Over the past year, “enterprise” PHP applications have seemingly exploded, with numerous new and high-profile companies announcing various PHP- and LAMP-centric (Linux, Apache, MySQL, PHP) products and services.
*ActiveGrid. ActiveGrid’s (http://www.activegrid.com/) flagship product, the Grid Application Server, builds upon the LAMP stack to create highly scalable applications capable of being spread across as many as 1,024 commodity servers. In a market dominated by Java-driven solutions, ActiveGrid is making great strides in offering organizations alternative opportunities to build truly large-scale, enterprise applications out of open source software.
*SugarCRM. SugarCRM (http://www.sugarcrm.com/) seeks to wreak havoc in the customer relationship management (CRM) software and services industry, by offering a LAMP-driven. open source solution at a significantly lower cost than proprietary alternatives. Users are free to download and deploy the open source version available at the Sugar Forge (http://www.sugarforge.org/). SugarCRM also offers an enhanced version of the open source edition, providing both fully hosted and downloadable versions on a yearly subscription basis. (You can read more about SugarCRM in the April 2005 issue of Linux Magazine, available online at http://www.linux-mag.com/2005-04/lamp_01.html.)
*SpikeSource. SpikeSource (http://www.spikesource.com/) offers an array of open source certification, support, and testing services, including an interesting combination of SpikeSource-certified open source stacks comprising fifty components (PHP 4 and 5 included). In addition to its array of open source products and services, earlier this year SpikeSource released Spike PHPCoverage (http://www.spikesource.com/projects/phpcoverage/), an open source reporting tool that works in conjunction with PHP 5, Xdebug, and XML_Parser to determine the code execution frequency.
*Zend. Of all the companies offering PHP-based products and services, perhaps none has benefited over the past year to the extent that Zend Technologies (http://www.zend.com/) has. Co-founded in 1999 by core PHP developers Andy Gutmans and Zeev Suraski, and Doron Gerstel, Zend has been profitable for two years, and is funded by a number of investors, including include Intel Capital and SAP Ventures. According to the Zend website, Zend boasts a customer base of more than 6,000 companies, including Lufthansa, Boeing, Sprint, and Disney. In May of this year Zend and Oracle announced an agreement to further extend PHP’s already solid support for Oracle’s namesake database by offering Zend Core for Oracle, a freely-available product intended to facilitate PHP and Oracle integration.
The pairing of Zend and Oracle followed in the footsteps of another major partnership involving Zend and IBM, in which the two companies announced that they would collaborate on a similar offering for IBM’s Cloudscape and DB2 databases, dubbed Zend Core for IBM.
Given the PHP development team’s penchant for moving the language forward, it likely won’t be too long before plans for PHP 6 are under way. Given the language’s amazing pace of maturation over the past several years, it’s difficult to fathom where it will go next.
True to their roots, the PHP team took little time to rest after the 5.0 release, continuing to chart the course towards 5.1. At the time of writing, a beta of 5.1 had been made available, boasting several new features including:
*A new database abstraction known as PHP Data Objects (PDO).
*Numerous performance enhancements, most notably the introduction of a new Zend Engine II execution architecture.
*An upgrade to the Perl-Compatible Regular Expressions (PCRE) extension to version 5.0.
*Countless improvements and enhancements to a wide variety of features, including XML support, SOAP, streams, arrays, the mysqli extension, and more.
It’s likely that by the press time the official 5.1 release will be available. In fact, the developers are already working towards the next major release. In a June 4, 2005 posting to mailing.www.php-dev, Andi Gutmans said PHP 5.5/6.0 could be available as soon as Q3 of this year. That release is expected to include the long-awaited support of Unicode.
Lerdorf’s now decade-old announcement signalled a new milestone for developers seeking a practical means for turning their vision into reality. It’s great to see that even ten years later, the vibrant PHP language and community is still providing that opportunity to users all over the world.
W. Jason Gilmore is the author of the bestselling “Beginning PHP 5 and MySQL: From Novice to Professional” (Apress, 2004. 758pp.). Along with Robert Treat he’s the co-author of the forthcoming “Beginning PHP 5 and PostgreSQL 8: From Novice to Professional” (Apress, 2005)