What are the main evolutions of the new version of the server scripting language? What contribution in terms of performance? The file of the editorial staff on PHP 7.
The final version of PHP 7 was released in December 2015 (read the official announcement on php.net). It comes with a new version of Zend Engine. A migration manual has been published by the open source project site.
What about the performance of PHP 7
“PHP 7 is faster.” This is the main promise made by Zend and the main contributors of the PHP project. This new version is based on PHPNG (for PHP Next-Generation). An initiative that was started by Zend in response to Facebook’s HHVM technology, which was intended to offer a version of PHP that was meant to be more powerful.
According to Zend, the upgrade of applications to PHP 7 could generate a performance increase of 25% to 70%. The publisher has published some indicators that it summarized in an infographic published in May 2015. These comparisons show that WordPress (in version 4.1) would be twice as fast with PHP 7 than with PHP 5.6, and Drupal (7) 70% faster. Through its benchmark, the PHP project also highlights a level of optimization that is at the same level as that of HHVM, or even slightly above (see infographic below).
First Benchmark of JDN
According to the first comparisons made by CCM Benchmark, the editor of JDN, the gains (between PHP 5.6 and PHP 7) can reach 50% inCPU execution time, and almost 50% also in memory consumption. “This is above what we anticipated. I have never seen such a performance differential during previous version upgrades,” notes Xavier Leune, PHP Framework Manager at CCM Benchmark (see article: PHP 7 vs PHP 5.6, the performance comparison of JDN).
What’s new in PHP 7
Zend had released last March an infographic that presented some developments in PHP 7. It mentioned the Spaceships which introduce a new comparison operator <=>. It can be used to combine comparisons (a decipherment in French here).
Another evolution mentioned, the Return Type Declarations & Scalar Type Hints allow to declare (optionally) a return type for functions and methods. Type Hinst like this new declaration can also support scalar types (to specify the expected return in terms of number or string). “This is very interesting. This will help simplify the management of input and output consistency,” comments Xavier Leune.
Why did PHP move from version 5 to version 7?
In July 2014, the PHP project contributors decided on a direct move from PHP 5.x to PHP 7.x (see the project wiki). In fact, PHP 6 did exist, but it remained in the works. This version was supposed to lead to the integration of Unicode to the language (in order to facilitate the manipulation of text in different languages). But facing too many technical difficulties, the initiative was abandoned. The other evolutions envisaged in PHP 6 have since been reintegrated into new intermediate versions (PHP 5.3 and 5.4). It is to avoid the confusion that was born then this idea to pass directly to version 7.
Finally for the supporters of PHP 7, the number 6 has also too often been associated with the notion of failure in the world of web development environments: “PHP 6 was a failure; Perl 6 was a failure. It’s actually associated with failure even outside the world of dynamic languages – MySQL 6 existed, but was never released.”