The Include of preloading ability into PHP-7.4 have been unanimously approved by the PHP team. This proposal; inspired by the “Class Data Sharing” technology designed for Java HotSpot VM; aims to provide users with the ability to trade in some of the flexibility that the conventional PHP model provides them, for increased performance.

Before running any application code, some PHP files may be loaded into memory and made permanently available to all server requests. All the functions and classes defined in these files will be available to requests out of the box, exactly like internal entities. This will preload entire or partial frameworks, and even the entire application class library.

Preloading PHP RFC vote

In the RFC proposal, Dmitry Stogov, reported that he got a performance improvement between 30% and 50%.  However, real world gains will depend on the ratio between the bootstrap overhead of the code and the runtime of the code, and will likely be lower. This will likely provide the most noticeable gains with requests with short very runtimes, such as microservices.

Preloading is going to be controlled by just a single new php.ini directive : opcache.preload. Using this directive we will specify a single PHP file – which will perform the preloading task. Once loaded, this file is then fully executed – and may preload other files, either by including them or by using the opcache_compile_file() function.

Preloading feature have been implemented as part of opcache and have been merged in PHP 7.4 branch. The new feature  does not affect any functionality unless it is explicitly used. However, if used, it may break some application behavior, because preloaded classes and functions are always available, and function_exists() or class_exists() checks would return TRUE, preventing execution of expected code paths.

Lot of deprecations are planned for PHP 7.4,  which could be the last minor release in the PHP7 branch. The deprecation RFC which is still in draft, proposes to deprecate the listed functionality in PHP 7.4 and remove them in PHP 8. Notice that while there is a clear PHP RFC for release processes, the upgrade from PHP 7.0 to PHP 7.1 didn’t went smoothly for many developers.

A discussion have been opened few months ago about upgrading from PHP 7.3 to PHP 8 instead of the 7.4 but without clear conclusion. Latest reports indicates that  61.5% of Websites still uses PHP5 which end-of-life is December 2018! The future upgrade from minor to major should be clear and smooth to help PHP developers upgrade easily to the latest versions for both features and security !

 

LEAVE A REPLY

Please enter your comment!
Please enter your name here