Time to update your PHP version

WordPress has PHP 5.2 as the minimum required PHP version. For a while now, PHP 5.4 has been listed as the recommended version. That’s a big step in the right direction, but I feel we can do more to help push the requirements forward.

At Radish Concepts we work with a lot of different platforms, frameworks and even languages. Most of our PHP projects are based on the Laravel framework, but we also do a lot of WordPress projects. When writing code for Laravel based projects, we obviously use namespaces and such, something we can’t do in publicly available WordPress plugins (since namespaces require PHP 5.3).

What we’d really love to do is be able to use namespaces for example, in our WordPress plugins as well. In addition to that, PHP 5.2 and 5.3 are really, really old. Even though lots of the Linux distributions tend to backport security fixes, it’s never a reassuring thought to read that PHP 5.2 has been unsupported for over 4 years now. We need to move on, as a community.

Require a PHP version in your WordPress plugins

What we needed to make this easier is a library that we can bundle with WordPress plugins. The library would require a minimum PHP version. We could then set this to PHP 5.3 or 5.4, based on what kind of code we’d write.

Of course we wanted to open source that library, so other developers could adopt it as well. Educating end users, or at least telling them why the plugin wont work for them, is really important, so we needed documentation as well.

WPupdatePHP logoThe result of all that is the WPupdatePHP website and library. Today, we’ve pulled the trigger and launched version 1.0.0, offering a really simple way to require a minimum PHP version in your plugin. If the server doesn’t meet that version, a notice is shown in the administration panel and the plugin developer can choose to disable the plugin.

Hopefully, this will be a small help for the WordPress project as a whole, to get those users still on really old PHP versions updated to more recent versions.

Require it for new plugins only

I agree, it’s not the nicest thing to do. I don’t like preventing people from using my plugins because of some technical reason they often don’t have any influence on.

Even though I think there aren’t that many websites, actively maintained and running PHP 5.2, I’d recommend implementing this library in new plugins only. As much as I want to get people off PHP 5.2, I don’t want to break peoples websites when a new version of a plugin suddenly requires a newer PHP version.

On the roadmap for version 1.1.0 is a secondary, “soft requirement” that will only show the informative notice but won’t stop the user from using the plugin. You could combine the two requirements though, requiring PHP 5.3, but recommending PHP 5.4 for example. I’m keen to get this out there as soon as possible, as that can make it a lot more attractive for developers to start bundling this library in their plugins.

When will WordPress bump the requirements?

As soon as WordPress bumps its own requirements, this library will become obsolete. At least, for a little while. PHP continues to evolve and release new versions. Using this library though, we can continue to push the requirements further. The website can grow with the project and newer plugins can require newer PHP versions, should the developer want to.

The first step towards PHP 5.4 as a minimum requirement has been made by listing it as the recommended version already. There have been talks for a long time on wether or not and when WordPress needs to pull the trigger and make PHP 5.4 actually required. This may take a little while though, as there are still indications of PHP 5.2 being used on live sites.