PHP version stats: January, 2022
It's that time again: my biyearly summary of which PHP versions are used across the community. It's been 6 months since my previous post and during that time PHP 8.1 was released. It'll be interesting to see some numbers on this newest version as well.
As always, it's important to note that I'm working with the data available to us. That means that these charts are no 100% accurate representation of the PHP community as a whole, but they are an accurate representation of one of the most prominent parts of PHP: the packagist ecosystem.
# Usage Statistics
Let's start with the raw numbers: the percentage of PHP versions being used, today and six months ago.
|Version||July, 2021 (%)||January, 2022 (%)|
Note that I've omitted all versions that didn't have more than 1% usage back in July, 2021. Visualizing this data looks something like this:
Evolution of version usage
It's good to see PHP 8.1 being used in almost 10% of all composer installs, only one month after its release. It makes sense that it's easier picked up on for projects already on PHP 8.0, since it's fairly easy to upgrade from PHP 8.0 to PHP 8.1.
I'm also happy to see PHP 8.0's growth, although PHP 8.0 and 8.1 combined only account for one third of all installs. That means that two out of three composer installs use a PHP versions that isn't actively supported any more.
Over the past years, I've been making it my goal to educate the people around me about the importance of keeping software up to date. I believe we — you and I — all have a responsibility to carry. If you want some hands-on tips on how to start, you can read this post about the why and how of managing PHP version ugrades.
two out of three composer installs use a PHP versions that isn't actively supported any more
Moving on the the all-time overview chart, here you can see the evolution of version usage across time.
All time evolution
Despite PHP 7.4 starting its downward trajectory, it's clear that it still has a way to go. Let's hope we'll see a steeper decline in six months.
# Required versions
Another interesting metric is the minimum required version across packages. I've used Nikita's popular package analyzer to download the 1000 most popular composer packages, and wrote a little script to get the lowest version they support from their
composer.json. Here are the results:
|Version||July, 2021 (#)||January, 2022 (#)|
You'll notice there are a little less than 1000 packages included, that's because some of the 1000 most popular packages don't specifically require a PHP version.
For visual learners, here's the same data visualised in a chart:
Minimal PHP requirement over time
You might be surprised not to see PHP 8.1 here yet, but keep in mind that this data shows the minimum required version. It doesn't mean that no packages support PHP 8.1, it only means they also support PHP 8.0 or lower versions. That makes a lot of sense given that PHP 8.1 has only been released for a little more than a month.
By the way, I'm talking about PHP 8.0 and 8.1 as if you're all already familiar with these newer versions. If that's not the case, or if you want 3-minute refresher about all the cool things that are happening in the PHP world these days, check out my video about modern day PHP!
So, in summary: I see similar trends as previous years, with the majority of composer installs still running outdated versions. I know many have good reasons why they can't or won't upgrade, but I also believe it has never been easier to stay up-to-date with modern PHP than it is today. Investing a couple of hours or days per year to keep your codebase healthy and up-to-date shouldn't be an issue for anyone. I hope you want to help create awareness for this issue. You can start by sharing this blog post or my recap video.
What are your thoughts on these stats? Are you already using PHP 8.1? Let me know your thoughts on Twitter and subscribe to my newsletter if you want to be kept up-to-date about these posts!