Power your WordPress website with PHP7!
We are happy to announce that PHP7 is now also available on our standard plans. Furthermore, all newly created websites are configured to use PHP7 by default.
PHP 7.0.0 was first released back in December 3rd, 2015. The announcement stated that this release would mark the start of a new major PHP7 series.
We recommend that you get slowly acclimated with PHP7, and start upgrading your website whenever you feel ready.
Why you should upgrade to PHP7
There are many reasons why this is important and why you should consider upgrading.
According to the official announcement, there are double, sometimes even triple, performance improvements over PHP 5.6. We wanted to find out exactly how much better PHP 7 performs and share our findings with you.
We planned a benchmark that would reflect an average day of traffic plus some scenarios for spikes. Overall we executed 5 tests of 5,10,20,40 and 80 concurrent (parallel) requests for 120 seconds under 4 different PHP configurations:
- PHP5 with no opcache
- PHP5 with opcache
- PHP7 with no opcache
- PHP7 with opcache
We used the siege benchmarking tool on a 2-Core, 4Gb RAM Linode instance, running a vanilla WordPress 4.6.1 installation, without any caching or other tricks. This test was specifically set up to measure the performance difference of PHP7. It does not represent the performance tests we run against our platform, or being indicative of our high-availability clustering capabilities.
The numbers speak for themselves. Below is a table summarizing the response times and transactions per second, for both PHP5 and PHP7.
PHP7 registered a 100% performance increase over PHP5, across all concurrency tests, delivering 2x transactions and half the response time.
We gathered lots of detailed data through the benchmarks, which we will showcase in future posts. But besides overall performance improvements, PHP7 sports several new language facilities and structures. Here are the fundamental ones:
Abstract Syntax Tree
An Abstract Syntax Tree is a design used in compilers to represent source code. This addition helps standardize the PHP compiler and make it more maintainable. It also enables the developers to implement some syntactical elements easier, without being restricted by technical limitations.
Return and Scalar Type Declarations
This feature improves PHP’s type system so that more bugs can be “caught” by the compiler before run-time. Less bugs in production running systems means more sleep!
Secure Random Number Generator
This feature will help developers implement better application security, a critical part of any web infrastructure.
Anonymous Classes
These are object structures that are well established in other object oriented programming languages (such as Java, C#, etc). These are used as standard practice since their inception.
Opcache support
Your PHP code is pre-compiled into bytecode at runtime. With opcache enabled this transformation happens only once, upon execution. Then the script is stored in memory leading to a significant performance boost.
WordPress recommended
WordPress currently recommends PHP 5.6 or better (version 7.0 came right after 5.6, creating a gap in the version numbering). However, according to a message posted in WordPress’ bug tracker forum , there are plans to stop supporting PHP5.6 soon.
Gary Pendergast, a core WordPress commiter, posted the following:
Given the PHP 5.6 support timeline, we’ll be bumping it by WordPress 4.8 at the latest, so it’d be nice to use those intervening months to ensure the UX for the wider WordPress ecosystem under PHP 7 is solid
Discover and explore PHP7!
There are plenty of reasons to get you excited about PHP7 and start exploring. From performance improvements to under-the-hood engine makeovers, and new shiny language features.
Just make sure that you have thoroughly tested your site after switching to PHP7 to rule out any compatibility issues that may arise.