The last two years didn’t only bring us lockdowns, anxiety, and uncertainty. For us PHP developers, they’ve been an exciting time too. The pace at which our language is evolving is astonishing.
At the time of this writing, the site PHP The Right Way mentions PHP 8.1 as the recommended version to be used for new projects. Check out this article to dig into the new features you can use.
In this article, we’ll share our in-depth performance benchmarks for various PHP versions and platforms so you know what to expect after an upgrade.
We benchmarked 5 different PHP versions across 17 PHP-based CMSes, including WordPress, Drupal, Joomla, Magento, SilverStripe, and Modx, and frameworks such as Laravel, Symfony, and more.
Let’s get started!
The State of PHP
Before going into the numbers, here’s some context to what you’re about to read.
Don’t believe the Twitter hype about PHP being dead. The truth is that PHP is still one of the most widely used programming languages, particularly when it comes to web development.
This is mostly due to the fact that WordPress is built on top of PHP and a huge portion of the web these days is powered by WordPress.
According to W3Techs, PHP is used by 77.4% of all websites whose server-side programming language they know. We would say that’s a pretty good indication of life, wouldn’t you?
But that’s not all. While many PHP detractors will argue that PHP is kept around for legacy code maintenance only, it’s a debatable claim for those who have been keeping tabs on what’s going on in the community.
Just the fact that the PHP foundation saw the light by the end of 2021 and is backed by big players in the industry is proof that PHP is here for the long haul.
But we can’t really hide the elephant in the room: most of the PHP-powered websites out there are still using outdated and unsupported versions of the language, which implies security risks and less than optimal performance.
Why is this? Well, one reason could be the conservative mindset shared by many IT managers, which arises from worries about backward compatibility issues and not-so-well-tested releases.
At the same time, everyone agrees that if there’s no innovation there’s no growth. So the right decision is not to leave things the way they are forever but rather to carefully plan and execute the appropriate migrations.
Before making such an important decision, you should weigh the benefits you’ll get from going through with it.
And that’s what this article gives you: a taste of the performance improvement you’ll experience due to the update efforts.
PHP Benchmarks (2022)
Every time a new version of a programming language comes out, it brings new features, bug fixes, and, in general, more efficient ways of achieving the same goals.
In the case of PHP, the pace at which this has happened has been accelerating since version 7. This has enabled developers to write more secure, maintainable, and robust code with less effort.
While those are certainly desirable features of a programming language, the only hard comparison that can be done is that about performance: how long does it take for two PHP versions to run the same code? That’s what we’ll be exploring through this article.
In order to be fair, we won’t be focusing just on one specific tool but rather on a selection of some of the most popular CMSes and frameworks with the hope of covering as much from the PHP universe as possible.
Bear in mind that not every platform supports every PHP version though.
Our Methodology
We benchmarked every tested URL spawning 100 requests per second over a 60-second period.
We measured the Average Response time through Loader.io.
Hardware Specs
You can find details of our test environment below:
Machine: 2 Core Processors, 4 GB Ram, 80 GB NVMe disk.
OS: Debian 4.19.208-1
Web Server: Apache/2.4.51
Database: MariaDB 0.4.20-MariaDB-1:10.4.20+maria~buster-log
PHP Versions: 7.2, 7.3, 7.4, 8.0, 8.1
Page Caching: Disabled on all platforms and configurations.
OPcache: Enabled OPcache on all platforms and configurations using the following settings:
opcache.blacklist_filename => no value => no value opcache.consistency_checks => 0 => 0 opcache.dups_fix => Off => Off opcache.enable => On => On opcache.enable_cli => Off => Off opcache.enable_file_override => Off => Off opcache.error_log => no value => no value opcache.file_cache => no value => no value opcache.file_cache_consistency_checks => On => On opcache.file_cache_only => Off => Off opcache.file_update_protection => 2 => 2 opcache.force_restart_timeout => 180 => 180 opcache.huge_code_pages => Off => Off opcache.interned_strings_buffer => 8 => 8 opcache.lockfile_path => /tmp => /tmp opcache.log_verbosity_level => 1 => 1 opcache.max_accelerated_files => 10000 => 10000 opcache.max_file_size => 0 => 0 opcache.max_wasted_percentage => 5 => 5 opcache.memory_consumption => 128 => 128 opcache.opt_debug_level => 0 => 0 opcache.optimization_level => 0x7FFEBFFF => 0x7FFEBFFF opcache.preferred_memory_model => no value => no value opcache.preload => no value => no value opcache.preload_user => no value => no value opcache.protect_memory => Off => Off opcache.restrict_api => no value => no value opcache.revalidate_freq => 2 => 2 opcache.revalidate_path => Off => Off opcache.save_comments => On => On opcache.use_cwd => On => On opcache.validate_permission => Off => Off opcache.validate_root => Off => Off opcache.validate_timestamps => On => On
The Results Of Every CMS We Tested
Let’s start analyzing how each PHP version performs when using a CMS on top of it.
WordPress 6.0
WordPress powers over 40% of all the websites on the internet. It’s mostly used for building blogs and it’s a free and open-source tool.
For starters, we tested its development version: 6.0 RC 3.
Results:
In terms of performance, there is not much of a difference between PHP versions 7.2 through 7.4 but things change when moving to 8.0 as the response time increases. However, with the PHP 8.1 update, the response time dramatically decreases, indicating that WordPress 6.0 RC-3 is prepared for the upgrade.
Success Response Count Hierarchy (Lower is better): 8.1 > 7.3 > 7.2 >7.4 > 8.0
WordPress Multisite
WordPress has a feature called Multisite, which allows the creation of several websites in a single WordPress instance. By activating it, users can manage a network of individual websites from one Control Panel.
In our case, we created a network of three websites for a WordPress 6.0 RC-3 installation.
Results:
The case of WordPress Multisite is similar to that of non-multisite WP, so it is best to go with PHP 8.1 as the response times are considerably lower than the older versions.
Success Response Count Hierarchy (Lower is better): 8.1> 7.2 > 7.3 > 7.4 > 8.0
Joomla 4.1.4
Joomla is another very popular CMS in the PHP ecosystem. Unlike WordPress, Joomla is aimed at more experienced users looking for more customization options.
Results:
Considering the above graph, PHP 8.0 has a significant advantage over its predecessors and even gives better response times than the newer upgrade, i.e., PHP 8.1.
Success Response Count Hierarchy (Lower is better): 8.0 > 8.1 > 7.4 > 7.3 > 7.2
SilverStripe
SilverStripe is a more recent CMS than WordPress. It offers more customization options for more sophisticated users.
Results:
The average response time with PHP 7.2 on SilverStripe is pretty higher than all its successors. As evident from the graph, the rates drops with each update, giving the best results with PHP 8.0.
Success Response Count Hierarchy (Lower is better): 8.0 > 8.1 > 7.4 > 7.3 > 7.2
Nothing as Easy as Deploying PHP Apps on Cloud
With Cloudways, you can have your PHP apps up and running on managed cloud servers in just a few minutes.
MODX
MODX is a CMS designed for security and performance. It offers most of the features found in WordPress or SilverStripe as well.
Results:
With ModX, the PHP versions don’t significantly differ in average response times. We still recommend moving to more current versions because of all the other benefits associated with them. If you want the best response times, then 8.0 is the clear winner.
Success Response Count Hierarchy (Lower is better): 8.0 > 8.1 > 7.2 > 7.4 > 7.3
Typo3
Typo3 is a CMS designed for corporate usage that enables easy scaling.
In this case, the comparison can only be made for PHP versions above 7.3.
Results:
If you’re running a Typo3-powered website, you should consider upgrading to PHP 8.0 or 8.1 from previous versions because of its more modern features and improved performance.
Success Response Count Hierarchy (Lower is better): 8.1 > 8.0 > 7.4
Craft CMS 3.7.30.1
CraftCMS is a CMS aimed at advanced users who can customize its features by creating their own code. At the time of this writing CraftCMS doesn’t support php versions above 7.4.
Results:
With CraftCMS, you should consider moving to 7.4 but don’t expect a tremendous gain in terms of performance. Also, CraftCMS does not support the latest PHP versions, i.e., 8.0 and 8.1, so the best option is to use PHP 7.4 (also recommended in CraftCMS’ documentation).
Success Response Count Hierarchy (Lower is better): 7.4 > 7.2 > 7.3.
OctoberCMS 2.0
OctoberCMS is a CMS created using the Laravel Framework and is aimed at developers.
Results:
OctoberCMS 2.0 does not support installations prior to 8.0. If we compare the response times on PHP 8.0 and 8.1, then going with the former is recommended.
Success Response Count Hierarchy (Lower is better): 8.0 > 8.1
Drupal
Drupal is a general-purpose CMS. It’s widely used within corporate environments to power intranets, knowledge bases, and online business collaboration.
The minimum PHP version for Drupal at the time of this writing is 7.3.
Results:
With Drupal, we recommend sticking to PHP 8.0 if you prioritize the average response times. An upgrade to 8.1 would be detrimental in this case, as the response times increase exponentially compared to the previous versions.
Success Response Count Hierarchy (Lower is better): 8.0 > 7.4 > 7.3 > 8.1
eCommerce solutions
The second category of applications we’ll be analyzing is eCommerce solutions, another very popular use case for PHP.
WordPress 6.0 + WooCommerce 6.5
WooCommerce is a very widely used WordPress extension that allows online selling. We tested version 6.5 on top of a WordPress 6.0 RC-3 installation.
Results:
The average response times prior to the PHP 8.1 version are almost similar for all versions. Upgrading to PHP 8.1 is highly recommended for WordPress 6.0 and WooCommerce 6.5 for performance improvements and low response times.
Success Response Count Hierarchy (Lower is better): 8.1 > 7.4 > 8.0 > 7.3 > 7.2
Magento 2.4.3
Magento is a solid and full-featured eCommerce platform. Unlike WooCommerce, it’s not based on WordPress.
Its usage is mostly for medium to big-size online stores that handle complex operations.
The minimum PHP version needed to run Magento 2.4.3 is 7.4.
Tested URL: /
Results:
For Magento 2.4.3, we recommend opting for PHP 8.0 for low response times.
Success Response Count Hierarchy (Lower is better): 8.0 > 7.4
PrestaShop
PrestaShop is an eCommerce platform that caters to beginner users, unlike Magento.
At the time of this writing, PrestaShop supports PHP up to version 7.4.
Results:
Prestashop seems to run slightly better on PHP 7.3 and PHP 7.4 than 7.2, and it does not support PHP 8.x+ versions yet.
Success Response Count Hierarchy (Lower is better): 7.3 > 7.4 > 7.2
Frameworks
The final stop in our journey is the analysis of some of the popular Frameworks (general-purpose libraries used to create custom rich applications).
In this case, what we did was to mount an instance of the default project each one provides and run our tests.
Laminas (Zend Framework)
Laminas is a PHP MVC Framework. The codebase is what used to be called Zend Framework, but the project got transferred to the Linux Foundation a few years ago and has since been a community-driven effort.
At the time of this writing, Laminas supports PHP version starting at 7.4.
Results:
The case for the frameworks is a little more challenging since most performance issues are found within the applications built on top of them rather than in the frameworks themselves.
In the case of custom-made applications, switching to PHP 8.0 makes a lot of sense since it will unleash new possibilities for you to serve your clients better. We don’t recommend upgrading to 8.1, as the graph suggests relatively higher response times on that version.
Success Response Count Hierarchy (Lower is better): 8.0 > 7.4 > 8.1
Improve Your PHP App Speed by 300%
Cloudways offers you dedicated servers with SSD storage, custom performance, an optimized stack, and more for 300% faster load times.
Laravel
Laravel is a PHP MVC framework designed to be easy to learn and implement. Laravel is currently one of the most widely used and loved PHP frameworks.
Tested URL: /
Results:
The graph clearly shows how the response times decrease after PHP 7.3 and give the best results on PHP 8.0.
Similar to what we said about Laminas, your decision to upgrade should be solely guided by performance considerations rather than the new features brought by the language.
Success Response Count Hierarchy (Higher is better): 8.0 > 7.2 > 7.4 > 7.3
Symfony
Symfony is a FullStack PHP Framework built around the principles of SOLID and other industry best practices. It can be a little more challenging for newcomers but, at the same time, it provides an environment suitable for long-term application maintenance.
Results:
The case of Symfony doesn’t fall very far from the other frameworks analyzed in this article.
The difference here is that Symfony quickly leverages new language possibilities to improve its code base, so we would recommend upgrading to PHP 8.0 for best performance results and low response times.
Success Response Count Hierarchy (Lower is better): 8.0 > 7.4 > 7.3 > 7.2
CodeIgniter
CodeIgniter is a simple PHP MVC framework aimed at rapid application development. PHP 8.1 works the fastest with CodeIgniter, performing 8.48% more requests per second as compared to PHP 8.0.
Results:
With CodeIgniter, the average response times are similar for all the PHP versions before 8.1, so we recommend opting for 8.0 for low response times and better overall performance results.
Success Response Count Hierarchy (Lower is better): 8.0 > 8.1 > 7.4 > 7.3 > 7.2
Yii
Yii is a PHP MVC framework designed for performance and ease of use.
Results:
Like CodeIgniter, the average response times with Yii are similar for 7.2 to 8.0 and increase with PHP 8.1. So, we would recommend choosing the PHP 8.0 version.
Success Response Count Hierarchy (Lower is better): 8.0 > 7.4 > 7.3 > 7.2 > 8.1
Conclusion
Keep in mind that performance is just one aspect to be taken into account when considering an upgrade. And while it is definitely an important one, it should not be the only factor driving your decision.
In fact, performance problems can be solved at the infrastructure level, by leveraging tools such as Varnish or Redis.
Pay attention to the language’s new features too. This is what helps create more powerful applications with less effort and the security improvements that come bundled with newer language versions.
And yes, migrating is not a trivial task but again, the PHP community has many resources at your disposal which can help you maximize your chances of success, such as Rector.
In any case, the safest way to perform this kind of upgrade is to first clone your current server into a privately accessible one (usually referred to as a staging server). Then, make the changes to the code at a relatively low pace and test that everything works as expected. Fix any problems you might encounter and, once you’re happy with the results, either promote this server to production (change the DNS definitions to point to the new IP). Or if that’s not a feasible option, replicate the changes in the original server.
Customer Review at
“Cloudways hosting has one of the best customer service and hosting speed”
Sanjit C [Website Developer]
Shahzeb Ahmed
Shahzeb is a Digital Marketer with a Software Engineering background, works as a Community Manager — PHP Community at Cloudways. He is growth ambitious and aims to learn & share information about PHP & Laravel Development through practice and experimentation. He loves to travel and explore new ideas whenever he finds time. Get in touch with him at [email protected]