Open menu

Need a Magento Development Team for You Store?

Hire us to speed up Magento! Open menu
PHP 7 Vs PHP 8: How They Affect Magento 2 Performance

PHP 7 Vs PHP 8: How They Affect Magento 2 Performance

PHP 7 Vs PHP 8: How They Affect Magento 2 Performance

PHP 8.0 Alpha 3 was released in July 2020 and brought us a whole bunch of robust features and improvements. Even though PHP 8.0 is still in active development and some issues remain unresolved, the features that will be available with the new final update are already known and can be tested. 

Undoubtedly, the JIT compiler (short for “Just In Time”) is the biggest deal for this version of the programming language. Basically, it is an approach that is used to optimize the running code. The tool translates PHP to machine code which can be executed on CPU. It is expected that by applying this method one can significantly improve the performance of such a massive platform as Magento 2. But is this really true? 

To make things clear, we’ve installed Magento 2 on PHP 8.0 Alpha 3 to check the page load time with JIT enabled and disabled. Additionally, we have compared PHP 7.3 and PHP 8.0 performance to find out whether it is worth switching to the new version of the programming language. We must say that we were quite surprised by the results of the conducted research.

  1. The Process of PHP 8.0 Installation: Milestones and Problems
  2. Installing Magento 2 on PHP 8.0: Problems and Solutions
  3. PHP 8.0 Alpha 3 JIT: Speed Testing on Simple Code
  4. PHP 8.0 JIT: Speed and Performance Testing on Magento 2
  5. PHP 7.3 vs PHP 8.0 Alpha 3: Speed and Performance Testing on the Magento 2 Environment
  6. Updating: PHP 8 Release Candidate 2 Is Available for Speed Testing on the Magento 2 Environment
  7. PHP 8 Release Candidate 2: Performance Testing on the Magento Environment and Another Installation Issue
  8. Conclusion

The Process of PHP 8.0 Installation: Milestones and Problems

The installation and deployment of PHP 8.0 are quite straightforward. We have not encountered any difficulties or problems throughout the processes. Only one minor obstacle can be mentioned: if you want the GD library to be enabled on your PHP server to manipulate files with Magento images, you need to install LibJPEG and LibPNG. Moreover, depending on the requirements, the GD library may oblige other libraries to be installed.

In order to compile, build, and install PHP 8.0, we decided to deal with the following server environment:

  • Amazon EC2 M5.xlarge instance offering 4 vCPU and 16 GiB of memory,
  • NGINX as a web server,
  • MySQL 5.7, an open-source relational database management system,
  • Amazon RDS for developing scalable MySQL servers.

We used Ubuntu 18.04 LTC to carry out the process. However, the procedure is basically the same for the rest of the operating systems (with few exceptions). But first things first.

1. Dependencies

Dependencies are packages, libraries, frameworks, and other components that are required for your project to run. To compile PHP from source, we need a number of them.

In some cases, installing these dependencies may not be enough to compile PHP 8.0. The rule of thumb is the following: install missing dependency with -dev suffix and/or -lib prefix. For instance, if you face the error pointed at the absence of the libxm12 library, you can fix it by installing the missing component with the following command:

Once all the dependencies are installed, we need the source code.

2. Clone PHP source code from a Git repository

The next step is to get the latest version of PHP which you can obtain through Git. For this purpose, we need to type the command: 

By default, we will end up on the master branch and the latest version of PHP will be copied. As far as our case is concerned, PHP 8.0.0-dev is installed.

3. Configure the compilation

By default, the configuration script with ./configure can not be found – don’t let that frustrate you. In order to generate one, you can force the ./buildconf script. Once it finally exists, we want to set up the compilation. For this purpose, we need to employ –prefix flag to configure all the necessary PHP modules that will be enabled on Magento 2 when it is installed on PHP 8.0.

If you don’t know what the particular configure includes, you can use ./configure –help to view the list of all the available options. If everything is done right, you will see a confirmation of successful configuration:

4. Build

Since our machine uses 4 cores to make a build, we’ve typed this number along with -j flag to make the process faster.

When the make is over, you should see the following script:

With that, we have to conduct standard tests to check whether the PHP compiled is working well. 

5. Install your compiled PHP

Now, we want to install the compiled binary to the system. This command initiates the process:

By default, your compiled PHP will be installed in this directory:

Now you can check if the binary works:

6. Enable required extensions

Since OpCache is an integral part of JIT, enabling OpCache that is used to cache opcode generated by Zend engine compilation is essential. According to


In order to activate the extension, specifying opcache.jit_buffer_size in php.ini is required. But first, you have to generate the configuration file and check the propriety of your path:

The next step is to create a php.ini file in the required directory. Then you need to load OpCache to the newly created file using the following command:

Thereafter, we want to check if the extension is loaded. We used -v option to ensure that everything goes as contemplated.

Installing Magento 2 on PHP 8.0: Problems and Solutions

Installing Magento on PHP 8 proved to be quite challenging. Despite the fact that Magento has its own installer and this process is pretty standard, we faced a number of issues.

  1. Since the Implode function in PHP 8 accepts its parameters in the strict, documented order (the separator is accepted first and then the array), this presents some challenges caused by the incompatibility of this order with the M2 core. In contrast, in PHP 7, the implode() function can accept its arguments in either order.Solution: The problem was solved by reshuffling these arguments manually. 
  2. With PHP 7 and below, types of arguments prefixed with “?” are validated by Magento 2. As such, the function returns the type without the prefix “?”. But things have changed with PHP 8. Since such a prefix is absent in the M2 core, this triggers an error as the function returns this prefix.Solution: Adding the types prefixed with “?” right in the Magento 2 core allowed to settle lots of errors caused by this issue and fix them en masse. 
  3. In PHP 8, the match word is not allowed for class naming. As some Magento 2 classes are termed as match, this triggers an error.Solution: We had to rename these Magento classes to fix the error.

PHP 8.0 Alpha 3 JIT: Speed Testing on Simple Code

The evolution of PHP is ongoing. JIT is the newest feature that is currently in work for PHP 8 which allows for the creation of faster web applications promising a significant increase in major performance metrics. 

We want to carry out a series of tests on simple code to ensure that is the case. To figure it out, we used the following piece:

The results are impressive! While PHP 7.3 demonstrated 73 msec, the eighth Alpha 3 version of this programming language showed 42 msec and 22 msec with JIT enabled. As you can see, the load time with the compiler involved increased by a factor of two as compared to PHP 8 without JIT and became more than 3 times faster than PHP 7.3 can offer.

PHP 8.0 JIT: Speed and Performance Testing on Magento 2

Having been inspired by the outstanding results, we proceeded with testing Magento 2.3.5-p1 with sample data and without FPC. First, we checked the home page’s load time without JIT. The median is 235 msec. It seems like the speed is low. Then, we enabled JIT on PHP 8.0 hoping to see a better performance. But we got 230 msec for the home page.

In order to confirm or deny our assumptions, we carried out the same tests for the category and product pages. On the category page, we saw 530 msec with JIT disabled and 480 msec when we turned the feature on. The same discouraging results are for the product page. We went with the average 290 msec for PHP 8.0 and 275 msec with JIT enabled.

This is weird but we didn’t get the results we’d hoped for. It looks like JIT doesn’t give as much performance on real applications as on simple code.

PHP 7.3 vs PHP 8.0 Alpha 3: Speed and Performance Testing on the Magento 2 Environment

Based on our experience, PHP 7 obviously works faster than the latest version. Therefore, we installed PHP 7 along with Magento 2 on the same machine. After that, we launched jmeter and made 100 consecutive requests to the server with one concurrent connection.

As is clear from the graphs below, the upgraded version showed inferior performance than the older one and this gap is relatively high. Thus, for the home page, PHP 7.3 works out 162 msec on average while PHP 8.0 extorts just 235 msec with JIT disabled and 230 msec with this feature turned on. 

On the category page, we got 420 msec with PHP 7 and 530 msec with the upgraded version. Provided that JIT made the version a little faster and delivered 480 msec.

With the product page, the situation has not significantly changed. PHP 7 demonstrated the best results with 205 msec. While PHP 8 lagged starkly behind with 290 msec and 275 msec with JIT turned on.

But let’s not forget that the new version of this language is still in active development, meaning that a whole team of professionals is working on it to improve the performance and fix bugs. As such, we may expect better page load speed on Magento 2 run web apps with the release of the PHP 8 Alpha 3 and subsequent versions.

Updating: PHP 8 Release Candidate 2 Is Available for Speed Testing on the Magento 2 Environment

It’s been about 2 months since we tested PHP 8.0 Alpha 3 performance on Magento. We promised to keep you informed with the latest updates of the programming language and run a new series of tests as further versions are released. Well, the long-awaited event has occurred! The PHP team announced the ninth testing release of PHP 8.0.0, Release Candidate 2.

Let’s see if this can speed up Magento 2 and increase the page load time compared to the previous Alpha 3 version.

PHP 8 Release Candidate 2: Performance Testing on the Magento Environment and Another Installation Issue

Put it bluntly, we expected to see at least minor improvements with the updated version but no miracles. After we launched the Apache jmeter application and made 100 consecutive requests to the server, we were frustrated by the results. The upgraded version showed no significant changes in terms of speed and performance on all the pages. Thus, for the homepage, we saw the same 235 msec with JIT turned off and 230 msec when we activated this feature. For the product page, the situation is in no way different – 530/480 msec with JIT disabled/enabled.

The bottom line: PHP 8 is still slower than PHP 7. Furthermore, we faced one more issue during the installation process.

The fact is that the newest version uses the call_user_func_array function which triggers an error.


The problem lies in the second parameter of the function, which basically defines the parameters of the called method. In Magento 2.3.5-p1, arguments are sent in the form of an associative array, where the names of the keys do not match the parameters of the called method. With the PHP 8 update, the way this function works has been changed. Now the keys must either match the names of the parameters or be absent.

Solution: This issue was solved by removing the keys so that the function can work correctly. 

The next release will be Release Candidate 3, planned for Oct 29, 2020.


PHP 8.0 is still under optimization. For the time being, the PHP 8 JIT is far from being useful in terms of improving the Magento 2 web application performance and optimizing Magento store speed. However, it is fair to say that the feature perfectly copes with its tasks on simple code. This means that PHP 8 along with its JIT both have room for growth and we hope to see the upgraded version soon. The Onilab team will keep a wary eye on the evolution of this programming language and update the article as some changes happen. And if you need a hand from professional Magento developers, we’re always glad to assist!

Magento tips from real projects
Magento tips from real projects
CALL US 24/7:
& asia
+61 (02) 8005-7494