We’re thrilled to announce PHP 8.0 is now available on Hostinger servers. This version comes with new features and changes to provide the best possible performance for your web projects.
Since this is a major update, we encourage all users migrating to the latest release to get familiar with the new changes which we will cover in this article.
Why Do You Need PHP 8.0?
The latest benchmark tests by Phoronix show PHP 8.0 is performing 10% better than its predecessors. This data suggests a promising future for PHP-based websites and applications.
Better yet, the test was not even conducted using the JIT compiler, a new optimization feature introduced with PHP 8.0. Developers can expect a much faster performance if it is enabled.
Furthermore, the version implements new features to make coding much quicker and cleaner, reducing plenty of boilerplate and redundant code.
Since this is a version update, your website will likely experience changes that might break it if you transition to PHP 8.0 without making any prior modifications. To help prepare for the migration, we will walk you through all the latest features.
Changing Your PHP Version
Hostinger clients can follow these steps to update their PHP version:
- Log in to hPanel and open your Hosting Account dashboard.
- Under the Advanced section, click PHP Configuration.
- The PHP Version tab will show which PHP you’re using. To update it to the latest release, select PHP 8.0 and press Save.
Note that the update may take a couple of minutes to complete and cause your website to be temporarily unavailable.
What’s New in PHP 8.0
There are plenty of quality-of-life changes coming with the new update alongside plenty of brand-new features. Let’s explore what’s new and what’s changing in PHP 8.0.
JIT (Just-in-Time) Compiler
The JIT compiler is one of the most exciting updates to PHP 8.0. This feature aims to work with opcache to improve performance in script execution.
What Is JIT?
Short for just-in-time, the JIT compiles opcode into machine code right before it’s run for output. To understand what that means and how it works, we need to understand the PHP script execution stages, which are:
- Lexical analysis. This step is where the Zend Engine, the PHP interpreter, translates the code into machine-readable tokens.
- Parser. The interpreter parses the tokens to generate the Abstract Syntax Tree (AST) – a tree-like representation that shows how the code works.
- Compilation. The interpreter converts the AST nodes into opcode which is a machine-readable instruction that tells the Zend virtual machine (VM) what operation to perform.
- Execution. The interpreter delivers the opcode to the Zend VM, which will compile the opcode into machine code for execution.
This process uses a significant amount of server resources, especially if a PHP script gets repeat requests.
That’s why PHP 5.5 introduced the opcache extension, which stores the opcode from the compilation stage.
When the server receives a new request for the same script, the interpreter can immediately run the opcode from the opcache. That way, there’s no need to restart the execution process from the beginning.
PHP 7.4 added a preloading feature several years later to have the opcache precompile scripts into opcode during startup. As a result, the interpreter can immediately deliver the opcode for execution when the server first receives a request for the script.
Despite these perks, there are several downsides. One is that towards the end of the process, the Zend VM still needs to convert the opcode into machine code before running it, which can take significant time and resources.
That’s where the JIT compiler comes in. It will compile the opcode into machine code during its first run to prepare for the next execution.
When there is a request for a JIT-compiled script, PHP will run it directly by the CPU instead of the Zend VM, resulting in faster performance. Here’s what the script execution stages will look like on PHP 8.0, in comparison to the previous version: