PHP 8 is a major update and a remarkable milestone in PHP, as it brings several new features in an effort to shape the future of a programming language that powers a significant portion of the Internet web sites and applications.
PHP tries to keep the breaking changes low, and yet, it brings several new major features to PHP 8.0. Features like Named Parameters, JIT, Attributes, and Constructor Properties bring major improvements and syntax changes, while several minor improvements such as resource to object migrations, improved error handling, and changes and improvements in operators and engine comparisons help seamlessly reduce the chances of overlooked bugs.
The JIT or just in time compiler is meant to bring performance improvements to web applications. JIT compiles and caches native instructions. It does not make a noticeable difference in IO-bound web applications, but provides a performance boost for CPU-heavy applications.
WordPress Core aims to be compatible with PHP 8.0 in the 5.6 release, however, this does not mean it is safe to upgrade to PHP 8 when WordPress 5.6 is released. WordPress is rarely run just on its own and usually relies on at least one theme and a collection of plugins to function as a blog or web site. The state of PHP 8 support within the broader ecosystem of plugins and themes is impossible to know. For that reason, WordPress 5.6 should be considered ‘beta compatible’ with PHP 8.
WordPress is only officially aiming to be PHP 8 ready by the time 5.6 is released in early December. Potentially, this means that many WordPress-focused hosting companies will only consider offering upgrades to their customers once WordPress core is compatible. So as plugin and theme developers, we have some time to test our products and get them ready, but that window is closing fast.
Although now new web development frameworks have arrived like NodeJS, Django, Flask, Laravel, Drupal, etc still PHP is a major player in the back-end market. PHP is a general-purpose scripting language especially suited to web development.
Versions of PHP prior to PHP 8 are more fault tolerant and try very hard to ensure that code will run even if minor errors are present.
PHP 8 uses much stricter typing than previous versions. Many built-in functions are now pickier about the input they accept, and PHP 8 itself is more stringent about how input is passed to functions. Issues that previously resulted in notices now result in warnings, and issues that previously resulted in warnings now result in errors.
In other words, PHP 8 is not as lenient as previous versions. It will not try quite as hard to make code work no matter what.
Each version of PHP has a life cycle of 2 years during which bugs are fixed, and an additional year during which security issues are patched. PHP 7.4 came out in November 2019. As the final version of PHP 7, this means that bugs in PHP 7.4 will be fixed until November of 2021, and security issues will be patched until November of 2022, at which point it will reach its “End of Life”. This means that November 2022 can be considered a hard cutoff date: all PHP code should be compatible with PHP 8.0 at minimum by this time, or risk being stuck on a potentially vulnerable version of PHP.
If you’re a website owner, start keeping a watchful eye on which of your plugins and themes are being updated or tested for compatibility and make a plan to replace the ones that aren’t. If you’re a developer, start testing your code and any dependencies on PHP 8, if you’re not already, and start making a plan to fork or replace any libraries that aren’t being updated.