Over a million developers have joined DZone.

PHP Version Adoption

DZone 's Guide to

PHP Version Adoption

· Web Dev Zone ·
Free Resource

PHP runs over 75% of all websites whose technologies are known (source: w3techs), which makes for a really REALLY long tail of users who once installed wordpress, phpmyadmin, or some other open source project that helped their business needs at the time. What they don't do is upgrade. PHP's current usage statistics look like this (source and raw numbers are if you want them):

PHP Version Adoption

What's alarming about this is that the left half of this graph represents unsupported versions of PHP. PHP 5.2 has been end of life since January 2011. This doesn't mean that you can't use it any more, but it does mean that in terms of security updates, you are out of luck. Some distributions will try to retro-fit some of the fixes but essentially your PHP applications seem a bit lacklustre because, well, you're using technology from 2006.

Where To Go From Here

Nobody chooses a PHP 5.2 platform, these things just happen, and I absolutely don't mean this post as a rant - more as a way of raising the issue and trying to give some pointers for moving forward. When I work with organisations to upgrade their platforms, usually either their hosting company is living in 2006, or they have a "supported" distro which prevents them from using modern technologies, or there's been no budget to upgrade, or ... really there are lots of (really valid) excuses. However good things await in newer versions of PHP!

PHP 5.3 has actual useful OOP features! We have anonymous functions (this feature will change your life, and for JS developers especially will make your PHP make more sense), the SPL extension is more than just iterators, and the DateTime extension is fabulous and finished in PHP 5.3. Also in PHP 5.3 (released 2009, it's not cutting edge) is the vitally important E_DEPRECATED error reporting flag. This will identify any features you are using in the current version of PHP which won't be available in the next version - if you are on PHP 5.3, or can get there, your upgrade path gets much easier! If you have a living PHP application, I can't recommend this move strongly enough.

PHP 5.4 has some cute new features, but whether you need them or not, PHP 5.4 has faster execution time and reduced memory footprint. Here's the graph from some benchmarks I did between versions of PHP last month - the Y axis is the number of seconds each version took, on average, to run the benchmark script included in the PHP source tree (raw numbers are available in a gist):

PHP Performance Across Versions

Whether you want to be able to use traits or not, PHP 5.4 will improve the performance of your application and reduce your hardware costs ... all you have to do is upgrade between versions of free software. Why isn't the PHP 5.4 segment on the first graph bigger? There are some explanations, such as the lack of APC, for this version, but nothing that seem compelling to me (happy to hear your stories in the comments).

PHP 5.5 isn't actually production-ready, as we're still in the release candidate phase for it, but it's probably weeks away. Look out though, a more regular release cycle for PHP means that there will be smaller incremental changes and we'll all be upgrading PHP the same way we maintain our other software - so pretty regularly. Beyond PHP 5.3, the effort and risk in upgrading is much reduced.

The Future

In truth, the future is already here for those people on PHP 5.4 and beyond. Keeping PHP upgraded is just part of our regular maintenance workflow, and the language is progressing in regular and manageable steps. If you've been left behind then I strongly recommend that you start making plans for upgrading your platform, or moving to a newer one. The effort will be well worth it when your application is still evolving and performing for many years to come! If any other platform gave away such incredible improvements in features and performance for free, it would be big news. Let's make it big news in PHP too.


Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}