UPDATE September 2021: With an even newer version of PHP on the way in 2021, here's a look at what's coming up in PHP 8.1.
Launched on November 28th, 2019, the PHP 7 release data saw Zend Technologies deliver a PHP 7 overhaul that drastically improved performance as well as provide a range of brand-new features. These improved on all areas of the language, bringing with it a new found user interactivity.
PHP 7 features
There were plenty of new PHP 7 features added with the PHP 7 performance improvement, many finally providing the PHP community with a programming language that could compete with more modern frameworks.
For starters, PHP 7 now operates 2x faster that PHP 5.6. Plus it has added the use of static type hints for static analysis and error detection, and now provides several other features that many experienced programmers might have previously considered missing.
One of the biggest inclusions was the addition of anonymous classes, allowing for improved testability within the PHP framework. Anonymous classes allow you to test abstract classes without extending them, as well as change the visibility of a property or method for testing purposes.
Other type hint additions included Scalar and Return type hints that enable far more flexibility in how you use types overall. The PHP 7 update also brought with it a wealth of new syntax options for users to play around with.
These are just a taste of the new features and we highly recommend picking up the PHP 7 manual to get fully versed with what the updated provided.
PHP 7 performance improvements
When compared to PHP 5.6, PHP 7 is incredibly efficient. To show this, Zend Technologies ran numerous performance tests on a variety of PHP applications to compare the performance of PHP 7 vs PHP 5.6.
These tests compared requests per second across the two versions of the popular scripting language, analysing the speed at which the code was executed, and how fast queries to database and server where returned.
At the end of all these tests, Zend Technologies demonstrated a visible overall performance increase of 100% for PHP 7. Below are some of the details for one of the tests conducted.
PHP performance on WordPress and Drupal
WordPress and Drupal, content management systems (CMS) that run on PHP, are used for personal or corporate blogs and websites. Between them they host over 25% of the websites on the internet.
A single WordPress request on PHP 5.6 executes around 100 million CPU instructions, whereas PHP 7 executes the same request with only 25 million CPU instructions.
The performance of WordPress 3.6 on PHP 7 was improved significantly compared to WordPress on PHP 5.6, with 112% more requests per second on WordPress PHP 7. And WordPress 4.1 executed 95% more requests per second on PHP 7 compared to PHP 5.6.
For Drupal, there were similar performance improvements on PHP 7 vs PHP 5.6. Drupal 7 on PHP 7 runs 73% faster, with 316 requests per second compared to 182 requests per second on PHP 5.6.
All of this means that PHP 7 provides faster coding for both WordPress and Drupal websites and themes, and a smoother interaction experience for the end user overall.
New PHP frameworks
A sort of ‘code template’, a PHP software framework is used to increase the efficiency of PHP application building. Instead of building each application from scratch, a software framework gives the developer a scaffold around which to build their PHP application. Software frameworks are made even more efficient with PHP 7. Laravel on PHP 7 serves 70% more requests per second than Laravel on PHP 5.6. And Zend Framework on PHP 7 serves 95% more requests per second than on PHP 5.6. This makes it even quicker for developers to build applications and requires less server space to do so.
Ecommerce on PHP 7
The ecommerce platform Magento drives more than 250,000 online merchants and is the most popular ecommerce platform in the world, with all of its systems running on PHP.
Again, there are significant performance improvements when running Magento on PHP 7 compared to PHP 5.6. There's 30% lower memory consumption with Magento on PHP 7, which means that one server can serve over three times as many user requests.
Homepage requests per second are improved by 68% on PHP 7, and catalogue requests per second are improved by 112% when compared to PHP 5.6.
This increased response time will decrease the time it takes for webpages to load. A lower page load time is vital for ecommerce websites as it’s been shown that 25% of users will abandon their visit if a page takes more than four seconds to load. In an ecommerce environment, a lost visit is as good as a lost sale.
How to install PHP 7
It's very easy to install PHP 7 on your device. Simply click on the official download link from the PHP 7 website and locate the download file. Then all you have to do is extract the zip, verify the installation, and follow the configuration steps to enable PHP 7 to work with your system.
For further information on PHP 7, you can read our guide on how to upgrade to PHP 7 on the Fasthosts website. You can also find out more about web hosting, dedicated servers on our website. Plus find other handy tips from Fasthosts by visiting our blog.