New Money, New Code Keep PHP Marching in March

PHP is on the march in March.

In a sign that the marketplace sees lots of promise in PHP’s growth prospects, Zend has completed a new venture capital infusion of $6 million. The latest investment, from venture capital fund Index Ventures, together with previous investors Walden Israel and SFK Technologies, brings to $12 million the total of VC investments in Zend in less than six months, since November 2003. Isreali-based news service Globes Online reports that Zend may actually get $2-3 million more in funding before the round closes.

And as if to justify investors’ faith, the long-anticipated PHP5 First Release Candidate is finally for download from Zend. To get a closer look at PHP5, OET spoke with Zend’s co-founder and Zend Engine co-creator Zeev Suraski.

PHP5’s FRC sports improvements in three (3) strategic areas that Suraski said will will better empower PHP’s use by enterprise devs, including:
(1) native SQL support,
(2) richer XML integration capabilities and even
(3) new object oriented technology to better synch up with Java (and eventually even .NET assets) “From our point of view there are several far-reaching improvements [in PHP5] that will enable larger, more complex projects to use PHP source code in the enterprise,” Suraski told OET.

Stronger Dynamic SQL Support
PHP developers looking for easier ways to create full-featured dynamic content applications can now avoid the hassle of needing to install or integrate with MySQL, Oracle or other SQL data engines. This comes in large part from PHP5’s inclusion of SQLite, which is not a “lite” SQL server engine, but instead is an Open Source SQL library that implements SQL syntax and a wide variety of other SQL features, including transactions.

SQLite is not an abstraction layer for SQL servers. It is a light-weight implementation of SQL that is very powerful, and if you have an application that doesn’t need a central database or doesn’t work with a cluster of servers, most low to medium scale applications you can use SQL without having to install an SQL server first.” Suraski told OET.

The implications could be major, especially for enterprise devs working on dynamic content or portlet applications. “Developers writing dynamic content applications typically needed database content, and so there was a natural barrier to entry for many developers because installing Oracle or MySQL or another database was not always thing to do. Now that barrier has been eliminated, said Brad Young, Zend’s director of product marketing.

The decision to implement SQLite into PHP5 is “good for small and mid-sized applications because the database lives on the same server as the application that is using it,” Suraski added.

Technically, “With SQLite, we’ve really put an SQL layer onto of a local [PHP platform], and regardless of your set-up, you can now support SQL on any server with PHP5. You import the data and leave it on the server,” Suraski explained, rather than directly tie PHP5 servers into a remote database.

SQLite also enables what Suraski calls “Round-trip PHP,” which enables PHP functions to actually be embedded into basic SQL query/calls against the database. “Because SQLite sits within PHP, and it’s not a client/server architecture, it’s built into PHP. So, one of the neat things you can do is call PHP functions within your SQL query. Select query by SQLite, you can bind the PHP function within the SQL function, and actually call that function within your query so you can do all sorts of neat things with it, Suraski told OET.

Other key PHP5 technical aspects of SQLite includes these advantages/features:

  • Supports sub-selects, views, transactions and even REPLACE
  • Completely typeless
  • Very fast performance (typically faster than MySQL, significantly faster than PostgreSQL)
  • Low memory footprint and
  • Can easily handle very large databases

Much Tighter, Easier XML Support.
The PHP5 upgrade will vastly improve native XML support from PHP devs, Suraski said. “Today, basically, people were used to working with XML typically along the lines of DOM. The PHP interface is now much, much simpler. XML, which is a very simple format language, all to often it became too complicated to actually write PHP applications that actually use it, so in PHP5 we’re bringing that to the level of trivial, which is what it should be.”

Technically, “XML [support] is basically now at the level of native data types in PHP now. This means you can manipulate the XML parsers as if they were PHP objects,” Suraski said.

Other key PHP5 technical aspects of XML support includes features that:

  • Take advantage of the new Zend Engine 2 Overloading API
  • Take advantage of the dynamic nature of PHP
  • Support XPath, Schema validation and
  • Wrap around standard libxml2

PHP Object Oriented Support
Some PHP devs have pushed the envelop of PHP’s capabilities in the enterprise, Suraski said, and as a consequence PHP’s object-oriented features have been “pushed to the limit.” To push PHP5 to the next level of OO support, to better enable PHP to work with the enterprise’s object-oriented languages, PHP5 will invoke a “handle-based” object oriented model at the engine layer.

For more detail, including code samples, of Zend’s new object model for PHP5, readers can go to one of the PHP5 areas on the Zend website.

Other key PHP5 technical aspects of engine upgrades for tighter OO support and integration outside PHP includes these advantages/features:

  • Static Class Members
  • Abstract methods & Interfaces
  • User-level Overloading
  • Class Autoloading through __autoload()
  • foreach() with references
  • Iterators and
  • Much improved overloading API

Among PHP5’s FRC enhancements that finds notable are:

  • The Zend Engine II with a new object model and dozens of new features.
  • XML support has been completely redone in PHP 5, all extensions are now focused around the excellent libxml2 library (
  • A new MySQL extension named MySQLi for developers using MySQL 4.1 and later. Additionally to a functional interface this new extension also includes an object-oriented interfaced and support for many of MySQL’s new features such as prepared statements.
  • SQLite has been bundled with PHP.
  • A brand new built-in SOAP extension for interoperability with Web Services.
  • A new SimpleXML extension for easily accessing and manipulating XML as PHP objects. It can also interface with the DOM extension and vice-versa, and
  • Streams have been greatly improved, including the ability to access low-level socket operations on streams.
    A complete list of PHP5 improvements since beta4 is available here. More PHP5 Resources 
  • For a tour of the website resources, Damien Seguy offers a breezy, easy-to-scan overview of all sorts of resources, ranging from code, comment boards, tips and you-name-it.
  • Zend presents a useful Future of PHP collection of links to slide presentations, overviews, tutorial resources and more.
  • Sourceforge offers a variety of PHP5 resources and list/groups. This group on Propel – PHP5 object persistence Propel is an object persistence and query service for PHP5 based on Apache Torque. Working from a simple XML schema to describe your data model, Propel creates SQL definition files for your RDBMS and PHP classes to query and manipulate your database.
  • The PHP Builder website sports a strong Introduction to PHP5 article, with code samples, written by Luis Argerich.
  • Harry Fuecks, the man behind PHP Patterns has also written a review of PHP5, effective with code relesaed in Beta 1 for Sitepoint. He is also manager of the PHP Patterns website, where PHP devs can get some helpful PHP development patterns, templates, code and tips.