We’re happy to announce that we have deployed the latest release of PHP 8 on all our hosting servers. The last time a major version was released was 2015, which was ages ago in Internet time. As always we are among the first companies to provide the new PHP on their hosting platform. PHP 8 is expected to facilitate developers to write cleaner code with better quality that gets executed faster.
What are the PHP 8 improvements and features
Just-in-Time (JIT) Compiler
One of the most anticipated features of PHP 8 is the JIT compiler, which pretty radically changes what is possible with PHP.
There are three reasons for its introduction:
- it allows for further optimization that would not be possible without it
- it may open the door for PHP being more frequently used in other, non-Web, CPU-intensive scenarios
- it can eventually provide users with the ability to develop built-in functions in PHP, instead of (or in addition to) C, facilitating future innovation
The PHP team has said,
PHP JIT is implemented as an almost independent part of OPcache. It may be enabled/disabled at PHP compile time and at run-time. When enabled, native code of PHP files is stored in an additional region of the OPcache shared memory and op_array->opcodes.handler(s) keep pointers to the entry points of JIT-ed code. This approach doesn’t require engine modification at all.
Constructor Property Promotion
It’s no secret that currently, PHP has a clunky way of dealing with objects. In all previous versions of PHP, the definition of simple value objects requires all properties to be repeated at least four times: in the property declaration, the constructor parameters, and twice in the property assignment.
Borrowing some syntax from PHP sister language Hack, the constructor property promotion introduces a shorthand syntax, which allows combining the definition of properties and the constructor.
Support for Union Types
Before PHP 8, properties, parameters, and return types could only have one type. With PHP 8, users can now declare more than one type for arguments, return types, and class properties.
Reclassified Engine Warnings
In PHP 8.0, the development team revisited engine warnings, many of which were outdated relative to their actual seriousness, for historical reasons. For example, accessing an undefined variable, while being a very severe programming error, only generates a notice. Here is a table of the redefined error types and their new level of warnings.
How to take advantage of PHP 8 on our platform?
All our clients can change the PHP version of their sites from within their cPanel by going to cPanel -> Software-> Select PHP Version. With PHP 8 being relatively new, we strongly advise that you do not enable it for your live sites, but run tests with it on a staging environment.
At the moment, we have deployed PHP 8 without the following modules: mcrypt, geoip, ioncube. These will become available on a later date as they are released for PHP 8.