Rachel H Kay Blog

The Need for PHP 7 Compatibility With WordPress

While PHP 7 has been out and about for a while now, it came into being around 2015, PHP 5.6 is still working great on WordPress websites. For a while the notion to make the big switch from PHP 5.6 to PHP 7 was more of a “you might want to consider upgrading to PHP 7”, to the now current “if you want to keep your site running smoothly with all those nifty little plugins, upgrade to PHP 7 soon”.

Why Should I Switch To PHP 7?

For some of my clients, whose sites have been working just fine on PHP 5.6, it’s getting to the point where upgrading to PHP 7 is going to have to happen. You can only run on outdated versions of those nifty little plugins for so long before that site becomes a security risk. Plus, not all hosting providers were offering PHP 7, which was the case for some of my clients, and why some plugins had to be run on older versions.

The next question then becomes, does my hosting provider support PHP 7? The main hosting providers I work with are Bluehost and GoDaddy. Bluehost supports PHP 7, although they aren’t pushing all their customers to upgrade just yet since some of those older websites aren’t PHP 7 compatible. Recently, GoDaddy began supporting PHP 7 as well. So if you use either of those hosting providers you no longer have any excuses on making the big switch, or at least begin testing for compatibility.

How Do I Test My Site for PHP 7?

Now that you know switching to PHP 7 is getting to the “must do it now” stage, you can’t just upgrade your server to PHP 7 and hope everything works out. You need to test for compatibility. The reason for this is because your theme, and those nifty little plugins you're using may not all be compatible. I know that can be a concern for a lot of people who really like the plugins they are using, or their current theme. But the good news is that a lot of plugin authors are updating their plugins to work with PHP 7, and some are even recommending it.

One of my clients uses an event manager plugin that threw their site out of whack with an update that was done a few months ago. After contacting the plugin author it was discovered that the issue was because the site wasn't running PHP 7. While it would have been nice to have a warning with that update it was nice to know that this particular plugin author was ensuring his plugin was going to work with PHP 7. Unfortunately this client has GoDaddy, and at the time they didn’t support PHP 7 yet. So I had to install an older version that would work with PHP 5.6 while we waited for GoDaddy to support PHP 7.

PHP Compatibility Checker

There are a few ways you can test for compatibility on your WordPress site. The first is a nifty little plugin developed by WP Engine called the PHP Compatibility Checker. This plugin will scan the code within your site, theme, and plugins to check for anything that may not be compatible.

Now you might be thinking this is going to be easy, but think again. While this plugin is a good start to checking for compatibility, don’t fully rely on its results. This plugin scans the code, it doesn’t run it. It just checks the code within your site for a list of functions that are deprecated for the version of PHP your testing. This doesn’t mean if you get a warning or an error about offending code within a particular plugin on your site that you have to switch plugins in order to upgrade to PHP 7, it just means you need to do a little more homework to see if these are false warnings or actual errors.

There is also a whitelist that is being compiled, which you can check to see if any plugins that are flagged with this scan are on the list. Also, keep in mind that this plugin requires WP-Cron to run, and it could get stuck if it isn’t running correctly. So check their FAQs for information on that.

After installing the plugin you’ll find it under Tools >> PHP Compatibility in your dashboard sidebar. You have the latest versions of PHP to test, from PHP 5.3, all the way up to PHP 7.0. So make sure PHP 7 is selected.

You can then choose to only scan active plugins and themes, or scan all plugins and themes. Choose the option that works best for you. If you might use any of those inactive plugins or themes in the future then select to scan everything. Then scan your site.

The scan itself might take a while to complete, but don’t worry, your site is still accessible to viewers while the scan is taking place. So just sit back and wait for the scan to finish.

Once the scan has completed you’ll see a list of results that looks like this:

Each plugin is given a color code: green, yellow, and red, which should be self explanatory, but green is good, yellow should make you look into the warning, and red should really get your attention.

The plugin you see in my example, Connections, that has a yellow warning and red error, also has an update available, so it could be that with an update this plugin would be compatible, or it could just be a false positive. Keep in mind that some plugin authors code their plugins with backwards compatibility to ensure their plugins work with various versions of PHP for those who haven’t upgraded to PHP 7 yet. This will also cause a false positive.

If you get any warnings or errors for a plugin, whether it has an update available or not, then my suggestion would be to contact the plugin author. You can click on “toggle details” to get all the details of what the PHP Compatibility plugin found, and copy and paste those details to send to the author of that plugin. It may be that the plugin just needs an update and the author I’m sure will be happy to help and get their plugin PHP 7 compatible. If you do find out that the warning or error was a false positive you can report it on WP Engine’s GitHub repo, which would be helpful in expanding their whitelist of plugins.

Another result you could get is the color code grey, which is unknown. Now don’t worry, this doesn’t mean you will never know any results on whether that particular plugin is compatible or not, it just means that there was a timeout issue.

This means that your server has a timeout that prevents long running queries, which is usually around 60 seconds. This can prevent the PHP Compatibility plugin from being able to process any themes or plugins that are rather large. You can check with your host to see if they can remove the timeout temporarily, run the plugin on a local copy of your site, or you can use a filter to customize the scan timeout. Here is an example of a filter that WP Engine provides on their FAQ page for the PHP Compatibility plugin. In the example, by setting the timeout to zero, the cron/timeout is disabled. Just make sure you remove your filter once you’re done running the PHP Compatibility plugin again. It’s only meant as a temporary fix.

Testing PHP 7 In A Local Environment

If you don’t want to install the PHP Compatibility Checker plugin, or you have used it and want to fully test your site before upgrading your live site to PHP 7 you can create a local environment, which is basically a copy of your website that runs locally on your computer.

Now for those of you who have no idea how to do this, or don’t want to go through the bother of setting up a local environment to test, which would require installing PHP and MySQL and then setting up your computer to then run PHP, there is a simple option using a bit of software called MAMP. First off the software is free, so that should settle some worries. While the install does also come with MAMP PRO, which is not free, you don’t have to use it. You can still do your testing using MAMP. On thing to note is that MAMP is for Mac OS X, you must be running Mac OS X 10.10.5 or later in order to use MAMP. If your OS is Windows then you may want to look into WampServer or XAMPP.

If you don't have MAMP setup on your computer, or don't know how to create a local environment, see this post "" for installing MAMP and setting up WordPress with your site files and database. If you already have MAMP setup on your computer and know how to install copies of your WordPress website into MAMP, great, your one step closer to testing PHP 7 on your website.

Choosing What Version of PHP To Test

For most of you who just want to test PHP 7 it may not matter, but what if the versions showing up aren’t the versions on your hosting provider's web server? Luckily there is a fix for that. You can download other versions and force MAMP to use the two versions you want.

Let’s say you want to test PHP 5.6.30 and PHP 7.1.8 for example. To do this you need to download those versions first. Close the MAMP preference pane, open your web browser, and go to MAMP Downloads. On the right, under “Additional PHP versions” you will see a list that has all the versions of PHP you can download. Choose the versions you want to download.

Once they are downloaded go to /Applications/MAMP/bin/php on your computer, add the PHP versions you just downloaded to that folder. Then go back to the preferences pane in MAMP to see which two versions show up. If you have newer versions than the ones you just downloaded they will show up instead. If a version you don’t want shows up just rename that versions folder in /Applications/MAMP/bin/php from “php7.1.8” to” _php7.1.8” for example, and any other versions that you don’t want MAMP to use. Then when you go back to the preferences pane in MAMP you will have the two options you want, PHP 5.6.30 and PHP 7.1.8, or whichever PHP versions you chose to test.

The reason for this step is that in order to fully test PHP 7 you need to compare it with the version of PHP your site is running now on your hosting companies server. That way you can see if there are any functionality issues, or display issues between the two, and make any necessary changes before upgrading your live site to PHP 7.

Now that you have the versions of PHP in MAMP that you want to test, you're good to go! So, what are you waiting for? Test your website and upgrade to PHP 7.

comments powered by Disqus

About Me

Hi there. I'm Rachel Kay, a Web Developer, Illustrator, & Designer, whose hobby is to be creative and artistic, while freelancing as a Web Developer building creative, modern websites.

Categories