A lot of you were probably wondering about the recent
announcements and discussions about the future of the PHP
scripting language. Youve probably heard the word
Zend at some point, a few shreds of information about
new features and functionalities, and thats about it.
In this article Ill try to lay out the way I see the future
of PHP in its upcoming release, version 4.0.
So, whats Zend?
Even though I hope that by now the answer to that is pretty
clear (at least to people from the PHP community), the myths and
pieces of misinformation that surrounded its announcement
probably warrant yet another clear explanation.
Zend is a piece of software (component, in Microsoft speak),
that implements a scripting language engine. Theoretically
speaking, its not directly related to PHP.
Practically speaking, the fact that it happens to
implement the very same language makes it the engine of choice
for executing PHP scripts.
Before Zend, PHP was powered by three different engines.
Rasmus Lerdorf, the inventor of PHP, has written the engines for
the first two versions of PHP/FI (he actually wrote just about
all of the other code that surrounded the engine for these
versions). Towards the end of 1997, Andi Gutmans and myself
have written a whole new engine that was later the base of PHP 3.0.
The new engine introduced increased performance and reliability,
a much more powerful and consistent language definition, and a
highly extendible API. All of you, today, benefit from the
features of this engine. The fact that I personally can no longer
remember all of the SQL servers and 3rd party libraries that are
supported by PHP demonstrates its tremendous success, not to
mention the various awards and enormous positive feedback it has
received.
Since PHP 3.0 introduced many new language features, and since
it was a very stable development platform, people began writing
complex PHP scripts and packages. Admittedly, PHP 3.0 wasn't
designed to run complex scripts or packages that include a large
number of files, in the sense that its efficiency dropped
significantly as the complexity of the script increased.
Recognizing this fact, Andi and I decided to try and design a new
engine, that will provide high performance for complex scripts,
without degrading the performance of short, simple scripts. That's
how Zend was born.
Unlike any of the previous engines, which weren't really
separate from the rest of PHP, Zend was designed as a standalone
library, that can be easily reused in programs other than PHP.
At this time, we have plans to incorporate Zend as a stored-procedure
language in the free high-performance SQL server, MySQL.
The fact that the code was written from the ground up to be
portable not only across computer platforms, but also across
different computer programs, makes this task feasible and doable
in a reasonable amount of time.
How does Zend fit in the PHP 4.0 plan?
Like its little brother, the PHP3 engine, Zend comes to solve
several deficiencies in previous versions of PHP. First, and
perhaps most importantly, it implements the same language as PHP
3.0, but does so in a much more optimized manner. Zend
typically executes PHP3 scripts at anywhere between 3 to 200
times quicker. Considering you dont have to change a
single letter in your script, but simply install a new version of
PHP thats a pretty important benefit. This
benefit is by far most noticeable on extremely busy sites, or
sites that implement complex logic in their PHP scripts. Zend
plugins, that will be available separately, will allow even
higher speed for sites that need to squeeze every last bit of
performance.
Zend introduces several new language constructs (like foreach,
class::method() calls, reference support and more), and also
remedies the most annoying problems of the PHP3 engine (notably,
nesting arrays within objects and vice versa; a true
implementation of unset(); and more). For a full list of
new language-level features or improvements, go to
http://www.zend.com/,
and select the New Features button.
In order to better understand how PHP relates to its engine (which
is very similar to the relationship between a car and its engine),
consider the following diagram:
As you can see, without the PHP modules and the wrapper layer,
all you would have is a nifty scripting engine, but not something
you can actually work with.
What about the rest?
PHP 4.0 will not be only about performance and improved reliability. Quite
a few additional improvements are scheduled for this release, and
are in various stages of implementation. First, the PHP modules
in the above diagram are scheduled to be much more modular than
they were in PHP 3.0. While you would still have the option of
compiling every module that comes with the PHP distribution as an
integral part of PHP, in version 4.0, we intend to make it
possible and easy to compile each module as a dynamic, loadable
module, and selectively load every module you wish at runtime.
The engine support for this already existed in PHP 3.0, but there
was no standard and easy to use build process to build dynamic
modules. This feature has already been mostly implemented by Stig Bakken.
Another major issue we intend to address in version 4.0 is the
Web Server interface. Version 3.0 had 3 supported interfaces -
standard CGI, Apache and fhttpd, Apache being by-far the most
popular one. In this new version, the Web Server interface is
going to be generalized in a way that would allow us to easily
support additional servers, most notably ISAPI (for Microsoft Internet
Information Server (IIS) under Windows NT) and NSAPI (for the various Netscape servers).
The multithreaded implementations will make use of the new thread
safe resource manager that we've developed for Zend (at this time,
Zend and PHP's core are 100% thread safe as they use this manager;
the various other parts of PHP are now being added thread safety). At this
time, abstraction layer modules have been completed for Apache, ISAPI and CGI
(yes, PHP now works natively as an IIS module, just as smoothly as it works as
an Apache module).
Finally, Zend's new features allow extended support for 3rd
party APIs, such as COM. A COM module will be included in the Win32
distribution of PHP 4.0, that enables full COM automation. Simply
put, it means you'd be able to access COM/DCOM objects from PHP 4.0
just as easily as you access them from ASP, using a full object-oriented
syntax. Note that Zend's core does not have any dedicated COM
support, thus, other OO interfaces, such as CORBA, may be also
supported in the future, provided someone writes a support module
for them.
To summarize, PHP 4.0 will not only be much quicker and
reliable than PHP 3.0, it'll also be more modular, portable and
feature-rich.
Schedule
Zend has been recently feature-frozen and finalized, and is
now going through a closed internal beta test. An alpha of PHP4
that uses Zend is being used and is based for further PHP 4.0
development of the additional features mentioned above. Assuming
we won't bump into any unexpected striking issues, I expect the
first public beta of PHP 4.0 to be released in late June or early July 1999.
--Zeev