From PHP 5 to 7
Since around 2005 we've heard talk about PHP 6 development. There have even been books sold about it. But where is it? As of July of this year it was decided that there won't be one and that PHP will skip directly to version 7. Why is it skipping to the next major version, and what ever happened with PHP 6? And if we're already jumping to PHP 7, what kinds of features will it have?
A Brief History
As most developers nowadays know, PHP is a server-side scripting language primarily intended for web development. It began in 1994 when a developer named Rasmus Lerdorf wrote a series of CGI binaries in C for the purpose of maintaining his personal homepage. This lead to the creation of "Personal Home Page/Forms Interpreter" or PHP/FI. PHP was not originally intended to be a new programming language, however it grew into one organically.
Then, in 1997, Zeev Suraski and Andi Gutmans rewrote the parser to form the foundation for PHP3. They additionally changed the language's name to its current, recursive acronym: "PHP: Hypertext Preprocessor".
In 2000, PHP4, powered by the Zend Engine 1.0, was released.
Now, according to a survey from Netcraft in January 2013, PHP was installed on more than 244 million websites and 2.1 million (of roughly 4.3 million) web servers.
What Happened to PHP6
In 2005, work began on a project headed by Andrei Zmievski to bring native Unicode support to the language by embedding the International Components for Unicode (ICU) library and internally representing strings as UTF-16. Because this project would lead to major internal and user-affecting changes, it was planned to be the next major PHP version (i.e. version 6) along with a few other features.
By using UTF-16 as default encoding, developers would need to convert the code and all input (e.g. data from requests, database, etc.) from one encoding to UTF-16 and back again. This conversion takes a lot of CPU time, memory (to store the much larger strings), and creates a higher complexity in the implementation due to the increased need to detect the proper encoding for the situation. In light of all of this and the relatively small gain, many contributors became unwilling to use "trunk" as their main development branch and instead either using the stable 5.2/5.3 branches or refusing to do development at all. This shortage of developers led to delays in the project.
In 2009, PHP 5.3 release with many non-Unicode features back-ported from PHP6, most notably namespaces. This became the widely used, stable version of PHP, and in March 2010, the PHP6 project was officially abandoned, and instead PHP 5.4 was prepared containing most remaining non-Unicode features from PHP 6, such as traits and closure re-binding.
Why Jump to PHP7
After a vote in July of 2014, it was officially decided that the next major release would be called PHP7. The primary reason for even considering the name is the widely-known existence of the previous failed attempt of a new major release, and the existence of numerous books and other resources which already referred to the previous PHP 6. To address potential confusion, there was an RFC (i.e. request for comments) and a vote on whether or not to reuse this name.
Here is a brief summary of the reasons outlined supporting the decision to release the next version as PHP 7:
- PHP6 already existed, and there are plenty of numbers available (so it's easy to make a new version number).
- It could confuse people since PHP6 was a widely known project, and this release is unrelated.
- There's lots of PHP6 information on the web which does not apply to this release.
- Skipping versions isn't unprecedented or uncommon in both open source projects and commercial products.
- The perception of version 6 as a failure - not as a superstition but as a real world fact (similar to the association of the word 'Vista' with failure) - will reflect badly on this version.
- Version 6 is generally associated with failure in the world of dynamic languages (because of PHP 6, Perl 6, and MySQL 6).
In the end it was decided to release PHP 7 as the next major version, arguing that the worst case scenario is that they needlessly skipped a version as opposed to the worst case of releasing it as PHP 6 which is widespread confusion in the community.
What's New With PHP7
The feature set for PHP 7 was not yet defined until very recently. Some of the rumored features which were worked on include:
- Major Performance Improvements: The main goal of PHPNG (PHP Next Generation) was to bring performance improvements that could at least match what Facebook HHVM provides.
- JIT Engine: The development of PHPNG was started with the motivation to research the implementation of a JIT (just-in-time) engine for the Zend Engine based PHP.
- AST: Abstract Syntax Tree: The generation of an Abstract Syntax Tree as an intermediary step for the PHP compilation process.
- Asynchronous Programming: The ability to easily implement support to the execution of parallel tasks within the same request
Now that the release date is getting close we have a bit more accurate information. The new features of PHP7 should include:
- Zend Engine 3 (performance improvements and 64-bit integer support on Windows)
- Uniform variable syntax
- AST-based compilation process
- Added Closure::call()
- Bitwise shift consistency across platforms
- ?? (null coalesce) operator
- Generator delegation
- Anonymous classes
- Unicode codepoint escape syntax
- Return type declarations
- Scalar type declarations (integer, float, string and boolean)
- <=> "spaceship" three-way comparison operator
- Simpler and more consistently available CSPRNG API
- Replacement of many remaining internal PHP errors with exception
- Shorthand syntax for importing multiple items from a namespace
For more information about the feature and how to prepare for them, see Migrating to PHP7.
PHP 7 was scheduled to be released November 12, 2015, however the community felt that it was not yet ready and is currently still under development.