Time to Upgrade PHP
4/13/2016 / By Derek Jones
4/13/2016 / By Derek Jones
Now that both ExpressionEngine 3 and ExpressionEngine 2 are compatible with PHP 7, you may be wondering whether it’s worth the trouble asking your host to upgrade PHP. Why fix what’s not broken, right? If your host is resistant, certainly it’s not worth shopping for a better host, right?
There are three common myths for not updating your PHP version:
Let’s dispell these myths.
The latest release of PHP at the time of this blog post is 7.0.5. Our hosting partner Nexcess offers PHP 7, on environments tuned for ExpressionEngine. But PHP 7 is available at quite a few more hosts than you might expect, and not just boutique hosts. InMotion Hosting, SiteGround, Media Temple, GreenGeeks, 1&1, Namecheap, and Dreamhost to name just a few.
Step one is to just ask, or check your host’s FAQs. PHP 7 is not yet the advertised default on many hosts, but plenty have it available as an optional free upgrade.
Dropping down to PHP 5.6, you can add dozens of other hosts to the list. Go further to PHP 5.5 and you can even add GoDaddy and HostGator to the list.
Myth: Web hosts don’t offer newer versions of PHP.
Fact: Even on the cheapest budget hosting, PHP 5.5 is available at minimum, and many if not most support PHP 7.
You can find many articles and comparisons from web hosts and the PHP community in general about the improvements in PHP 7. We think the results speak for themselves. In general, applications can get an average of 100% increased performance by moving to PHP 7. Rasmus Lerdorf, founder of PHP, recently talked about that gain from an interesting perspective:
In theory, you could turn off half the servers in your data center [and still have the same performance as was experienced before to moving to version 7].
Let that sink in a bit. As a developer, think of how much slower your apps are by running older versions of PHP. As a business owner, think of the money you’re wasting by hesitating to upgrade. As someone who cares about the environment, think of the energy and resources you’re consuming running applications on older versions of PHP.
Sadly, we see 20–30% of ExpressionEngine installs still running PHP 5.3. This has influenced our minimum requirement to remain low (5.3.10). Our hope is that these two charts will help those on PHP 5.3 see that it is a real problem.
These tests are specific to ExpressionEngine, and memory usage will vary from site to site. But the ratio of reduction will be pretty consistent. Likewise with transactions per second, no two sites are alike, so I’m just showing the amount of increase. And look how terrible by comparison PHP 5.3 and 5.4 are when you aren’t using an opcache.1
Myth: Updating to a newer version of PHP won’t make a significant difference if your code works in older versions.
Fact: Newer versions of PHP are tremendously faster and more efficient than older ones. They use a fraction of the memory and run twice as fast or greater.
Compatibility concerns should lead you to take stock of your implementation before upgrading to PHP 7. You need to check to make sure the add-ons you are running, whether from third parties or built in-house, are compatible with PHP 7. It does have a few backwards incompatible changes, and some deprecations that will generate PHP error messages.
That said, most of the changes are easy. Even on an app as large as ExpressionEngine, getting compatible took less than a week, with the bulk of the work taking less than a day. For most add-ons there will be anywhere from zero changes to a few minutes of work. For complex add-ons, it may need a few hours to change and test.
Your web host’s PHP versions may have different environments and PHP module availability. You can resolve that if it arises through their support systems, as it’s probably something they just missed. But we have seen this cause temporary issues on budget hosts until they resolve the discrepency.
Myth: Upgrading to a newer version of PHP will break my web site.
Fact: While it is wise to check compatibility before upgrading, bringing old code up to speed is not difficult or time consuming. Any problems are likely to be temporary, and this potential cost does not outweigh the gains of upgrading. In a worst case scenario where you or your host lack the skills to make things compatible, you can always downgrade your PHP version.
Simply put, everyone should look at upgrading to PHP 7. And with PHP 5.5 being available even at the cheapest of web hosts, there is no excuse for anyone to still be running PHP 5.3 or 5.4. Both versions make up over 50% of the current worldwide PHP usage. That means many of you reading this right now can double or triple your site’s speed and use less memory just by sending a support ticket to your host and requesting a PHP upgrade. For everyone else running PHP 5.5 or 5.6, go ahead and slide up to PHP 7. You’ll be glad that you did. Maybe you’ll save a million bucks.2
Opcaching or “opcode caching” is the server’s ability to cache the compiled PHP that your application uses. Without it (or when the cache is flushed), PHP has to compile before it can execute, and this is an expensive operation. After it is cached (likely APC on PHP 5.3 and 5.4, and the built-in OPcache module in 5.5+), later requests use fewer resources. ↩︎
“How Badoo saved one million dollars switching to PHP7”: https://techblog.badoo.com/blog/2016/03/14/how-badoo-saved-one-million-dollars-switching-to-php7/ ↩︎
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.