PHP 8.0.1 may have been officially released on January 7th, 2021, but we decided to evaluate its integration with cPanel and our infrastructure to ensure it would be 100% compatible and our customers wouldn’t have any troubles.
We are happy to announce that PHP 8 is now available to all ChemiCloud customers. 🎉
Let’s dive into some of the most exciting improvements and new features that will make PHP 8 faster and more reliable.
PHP JIT (Just in Time Compiler)
The new PHP JIT feature is something many, many developers have waited for and is the most acclaimed feature of the PHP update overall.
The RFC proposal describes JIT as:
“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, the 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.”
The JIT – or Just In Time – compiler promises huge performance increases over OPCache for CPU Heavy Applications. If you aren’t using any caching modules on your site, you’re missing out. And for those of you who are using caching, like OPCache, enabling JIT on apps that need a lot of CPU, like WordPress, Magento, and Drupal, should give you a significant performance increase.
It’s important to keep in mind, JIT is still very new and bug fixes are still rolling out for it, so keep this in mind while using it.
You can always find release notes on the latest changes and improvements to PHP here.
Other Major Improvements and New Features
- Union Types – These extend type declarations (return types, parameters, and class properties) to declare more than one type. They also support false as a special type (for Boolean false), a trait that’s prevalent in legacy code that did not use Exceptions.
- Named Parameters – This release now allows named parameters in function/method calls in addition to traditional positional parameters. This makes the function/method parameter names part of PHP’s public API.
- Constructor Properties – A new syntax to declare these class properties right from the class constructor (_construct magic method). In this feature, PHP now supports declaring the visibility of these as public, private, or protected, as well as their type.
- Attributes – These allow for the declaration of meta-data for functions, classes, properties, and parameters.
- match expressions – These are similar to switch blocks, but match blocks provide type-safe comparisons, support a return value, and don’t require break statements to break-out, and they also support multiple matching values.
- Null safe operator – This provides safety in method/property chaining when the return value or property can be or needs to be null.
- WeakMaps – this allows you to store and associate arbitrary values for object keys, without preventing the garbage collector from clearing it if the object falls out of scope somewhere else.
Deprecated Features in PHP 8
We always like to mention deprecated features so our readers are aware and can update their code accordingly:
- PostgreSQL: Several aliased functions are deprecated
- Deprecate required parameters after optional parameters in function/method signatures
`ReflectionParameter::getClass())`, `::isArray()`, and `::isCallable()` methods deprecated
- Disabled functions: Reflection and `get_defined_functions()` deprecations
- `libxml_disable_entity_loader` function is deprecated
For a complete list of improvements, new features, and deprecations, be sure to review the PHP.net official documentation and change log here.
How to Switch PHP Version to PHP 8 in cPanel
PHP 8 is available for all ChemiCloud customers. Before doing the switch to PHP 8 we strongly recommend you to check the compatibility of your website’s code with the new PHP version. Some web apps, themes, or plugins may not be fully compatible with PHP 8 yet.
You can easily update your PHP version to 7.4, from cPanel, using the PHP Selector by following the steps described below:
1) Log in to your cPanel account.
2) Navigate to the Software section and click on Select PHP Version.
3) Click on the PHP Version drop-down box and select PHP 8 version:
Important Note Re: WordPress 5.6 & PHP 8
WordPress version 5.6 (the latest release) officially supports PHP 7.4. Using PHP 8 with WordPress should be done with caution and it is not recommended at this time to run PHP 8 with your production site.
While WordPress will run on older versions of PHP, like version 7.2, it is not recommended as PHP 7.2 reached EOL or End Of Life on November 30, 2020, which means it is not receiving any security updates, and using it will expose your site to possible security vulnerabilities.
PHP version 7.4 will reach the end of life on November 8, 2022, which gives WordPress roughly 2 years to bring it up to date with the new standards introduced in PHP 8. The updates to WordPress should come well before that time, however, knowing how swift the WordPress teams work.
WordPress has stated that it’s latest release, Simone version 5.6, is beta compatible with PHP 8, but you should use it with caution as it is still possible undiscovered incompatibilities may exist. To quote the WordPress team:
“WordPress Core aims to be compatible with PHP 8.0 in the 5.6 release (currently scheduled for December 8, 2020).
…Significant effort has been put towards making WordPress 5.6 compatible with PHP 8 on its own, but it is very likely that there are still undiscovered issues remaining.”
Additionally, themes and plugins may not yet be compatible with PHP 8, and using it could introduce further complications with your websites. There are many old PHP functions from PHP version 7.4 and earlier which were removed in PHP 8, which means that themes and plugins which use those functions will break in PHP 8.
In this post, we covered some of the new features that we can expect with the release of the PHP 8 version. If you’re looking for the full list of features, updates, and deprecations along with the official documentation, check out the following resources:
If you’re a ChemiCloud client, you can already update to the latest PHP version using the PHP Selector in your cPanel.
Additionally, if you are using WordPress, consider waiting until WordPress releases a version stated to be fully compatible with PHP 8 before upgrading your PHP version.
Questions? Comments? Leave a note below!