The requirements page on the WordPress website, recommends using PHP 7. However, it states that PHP 5 can still be used to run WordPress. Currently, it reads:
Note: If you are in a legacy environment where you only have older PHP or MySQL versions, WordPress also works with PHP 5.6.20+ and MySQL 5.0+, but these versions have reached official End Of Life and as such may expose your site to security vulnerabilities.https://wordpress.org/about/requirements/
In this article, we will explore the reasons why we hope and encourage WordPress to drop PHP 5 support completely and embrace PHP 7 as the minimum version required, even 7.4. The main reasons are security, language features, speed, and future proofing WordPress.
This is one of the top reasons for dropping PHP 5 support in WordPress and other applications. PHP 5 and even 7.1 and 7.2 have reached the end of their lives. See the PHP supported versions page for more info. 7.3 is close to getting there.
It has been a long time since PHP 5 received security updates, and with each passing day, the chance of vulnerabilities being discovered and exploited increases. Running any application that is no longer being updated, especially one as large, low-level, and critical as a programming language runtime, is risky.
Some distributions such as old versions of Ubuntu (16.04, I think) and others still under Long Term Support (LTS) may be supporting PHP 5 still with patches. This is due to their commitment to support all their packages for a certain amount of time. If this is the case and one is running on one of these distributions, it is a bit safer. However, unless there is a good reason not to, one should upgrade to a newer version and take advantage of what PHP 7, and in the future, PHP 8 have to offer.
This is one of the biggest reasons to leave PHP 5 behind. PHP 7 introduced many new language features that make working with the language much easier and evolve the language to better serve its users. From scalar type declarations adding a bit of compile time type checking, to the null coalescing operator simplifying assignments. These features have become the bread and butter of the modern PHP developer.
WordPress needs to catch up. By eliminating support for PHP 5, WordPress and more importantly, the plugin authors can upgrade their code to use these new features. New plugins can be written with the new features enhancing code readability and usability. If support is not eliminated, plugin authors will feel compelled to write code for the largest audience, and thus be limited to PHP 5 language features.
Having a thriving network of developers is important and using modern language versions and features is crucial to this. No developer will want to work in WordPress if they are stuck on an old PHP 5 codebase when they could be doing modern PHP development with 7 or 8 and leveraging what is essentially, a much cleaned up and updated language.
Finally, there are also many things that were deprecated or scheduled to be deprecated in PHP 7. Some of these were features that led to their own security issues or were inconsistencies or performance issues. Upgrading code and getting rid of code using these deprecated features is crucial to keeping WordPress and its plugins working optimally and allowing them to work with future PHP and WordPress versions.
Speed: PHP 5 vs PHP 7
A huge speed gain was seen by almost all code moving from PHP 5 to 7. In my own tests, I noticed a roughly 2-2.5x speed-up. That’s over 100% speed gain or a reduction of over half of the total running time. Same code deployed to different PHP runtimes differing only by version. This alone should have one rushing to upgrade.
Speeding up all WordPress requests by a factor of two is quite noticeable and is not an easy task. There are many areas where one can make gains in regard to entire site performance. However, cutting server response times in half is certainly a huge win that is unlikely to come in any other way or at any other time. The folks working on PHP have done an amazing job with version 7. Version 8 has ever more amazing features in store, like a JIT, and could bring another speed boost.
Finally, it’s worth noting that there are even speed gains between version 7.0 and 7.4. The speed gains don’t stop with major versions. Each version often brings gains along with security fixes, bug patches, and new features.
The final category is future proofing. Making WordPress a viable platform for development in the future. We touched upon this when discussing language features, upgrading, and deprecation of old features. It’s important to keep WordPress development going in the same general direction as PHP development. Using new language features, supporting the newest versions, and dropping support for old legacy versions that are holding things back is key.
Also, attracting and keeping developers on the platform is key. The GPL license (see our discussion here) plays a huge role in this. It attracts developers and creates a huge community of great plugins and themes, many of which are on our site. The technical side to this is WordPress and PHP being and staying a viable platform for development. Both new and advanced developers want to work with WordPress. Both should be accommodated. By modernizing the platform, WordPress will bring in and keep more experienced developers without scaring away the beginners.
Conclusion: Drop PHP 5
In conclusion, there are many reasons for WordPress to drop PHP 5 support. Security, language features, speed, and future proofing are the top four. We examined each of these ideas and showed why it’s advantageous from multiple viewpoints for WordPress to modernize. Finally, we looked into what the future of WordPress might hold as PHP 7 itself will give way soon enough to PHP 8.