We’re thrilled to announce EarlyDog, our fully managed hosting on Google Cloud servers EarlyDog: managed hosting on Google Cloud

PHP 8.0 Available on All Servers

November 26, 2020

PHP 8.0, officially released today, introduces breaking changes to the PHP language. These changes are a necessary step in making the PHP language easier and more enjoyable to use.

Many PHP applications will need time before they support PHP 8.

PHP 8 is not faster than PHP 7.4 for the vast majority of web applications. There are many great new features and language improvements, but speed improvements for web apps was not the focus of PHP 8.

Unless you're a developer who needs to make your code compatible with PHP 8 or you're testing this latest PHP version to help developers identify problems, we recommend waiting until February to switch to PHP 8.

Of course, if you're a PHP developer wanting to use new features and syntax of PHP 8, you can get started anytime. You may find the PHP 8 questions on Stack Overflow helpful.

PHP 8 Changes

For the first time, the official PHP site has published their own great announcement page.

As always, they've also published a migration guide to help developers make their existing code compatible with PHP 8.0.

WordPress Compatibility with PHP 8

WordPress intends to have beta compatibility with PHP 8.0 in the upcoming WordPress 5.6 release scheduled for December 8. At that time, WordPress Core will not yet be fully compatible with PHP 8 and many WordPress plugins will still not be compatible.

Progress on PHP 8 support in WordPress can be followed on make.wordpress.org.

JIT Compiler

The most misunderstood feature of PHP 8 is the addition of a JIT compiler.

PHP 8 actually includes two JIT compilation engines, not one. Why two? JIT compilers don't always improve performance, they can even hurt performance. Depending on the particular code and application, different approaches to JIT compilation have different impacts on performance.

What Is a JIT Compiler?

A Just-In-Time (JIT) compiler is a speed optimization technique used in interpreted languages like PHP and JavaScript. That's actually what PHP itself is: an interpreter. When an application like WordPress is run, the app's source code is read by the interpreter. The interpreter is like a translator that's continuously translating source code into actions.

Interpreted languages are inherently slower than compiled languages such as C and Go. In compiled languages, before the program can be used, the program has to be turned into low-level instructions that can be executed directly by a CPU. That's what a compiler does: turns source code into machine code that can run directly on the hardware.

A JIT compiler is an advanced technique used by interpreters to identify and compile into machine code, while a program is running, sections of the program that are being repeatedly executed. A JIT compiler can speed up certain types of programs. However, a JIT compiler has to temporarily slow down a program in order to perform that compilation. As a result, a JIT compiler has to be very careful about which code it compiles. If the time it spends compiling a section of code is greater than the time saved in subsequent executions of the same section of code, then the JIT compiler will actually slow down the program rather than speed it up.

All JavaScript engines now include a JIT compiler. However, JavaScript is used differently than PHP. JavaScript code is interpreted when a web page is loaded and the same code may be executed many times, especially with single-page JavaScript applications like Gmail where it is infrequent to reload the entire page.

Does the JIT Compiler Benefit WordPress?

In PHP web applications such as WordPress, there's little benefit from a JIT. A PHP script handling a request is very short-lived, normally lasting only a few tens of milliseconds (the time it takes to generate a response to that single request) before exiting.

The PHP 8 announcement includes benchmarks showing WordPress is very slightly slower with one of the JIT compilers and very slightly faster with the other. These benchmarks don't likely reflect real-world WordPress applications using plugins and custom themes, which may not benefit at all from either JIT compiler.

PHP's JIT is very helpful for long-running programs written in PHP, which is a very uncommon use case for PHP. For web applications, PHP's new JIT is mostly a hint at what the future of the PHP language could be. Along with that, there are questions about whether the complexity of PHP's new JIT will be worth the increased bugs and development effort required to improve and maintain PHP. Only time will tell.

All that said, as users of PHP, we should not forgot how much time and energy is put into developing the language. Many new features take years to grow into foundational improvements that benefit users.

Enabling the JIT Compiler

ServerPilot currently does not enable the JIT in PHP 8.0. This is because the design of the JIT as well as current benchmarks show that it may hurt web application performance rather than improve it.

If you do want to experiment with the JIT, see our article on enabling the JIT in PHP 8.

Unless you're dealing with a long-running CPU-intensive PHP program that is not a web application, enabling the JIT for performance improvements will probably not be a good use of your time.

How to Switch to PHP 8

You can change an app to use PHP 8 through your app's Settings in ServerPilot. If your app does not work with PHP 8, you can easily change back.

Over the next week, we'll be updating all servers from the PHP 8.0 Release Candidate to the first PHP 8.0 General Availability release.

As always, please contact us if you have any questions.