Recently I set up GitHub sponsors, if you my content helps you, you can consider a one-time or monthly sponsorship.

PHP version stats: January, 2023

It's that time again: my biyearly summary of which PHP versions are used across the community. You can read the previous edition here.

As always, it's important to note that I'm working with the data available to us. That means that these charts are not a 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.

This blog post was sponsored by Private Packagist - the private Composer repository from the creators and maintainers of Composer & Packagist.

# Usage Statistics

Let's start with the percentage of PHP versions being used today, and compare it to the previous three editions, note that I've omitted all versions that don't have more than 1% usage:

Version 2021-07 2022-01 2022-07 2023-01
8.2 0.0% 0.0% 0.0% 4.7%
8.1 0.1% 9.1% 24.5% 38.8%
8.0 14.7% 23.9% 20.6% 16.2%
7.4 46.8% 43.9% 38.4% 27.7%
7.3 19.2% 12.0% 8.0% 5.3%
7.2 10.4% 6.6% 5.1% 4.3%
7.1 3.8% 2.4% 1.9% 1.8%

Visualizing this data looks like this:

Evolution of version usage

We can see a decent growth for PHP 8.* versions, I think that's great news! It's also great to see PHP 8.0 usage already declining: PHP 8.0 went into security fixes only mode at the end of last year, and I hope to see its usage decline a lot more this year. Keep in mind that PHP 8.0 will reach end of life on November 26, 2023. So it's crucial that projects start preparing to upgrade in the coming months.

PHP 7.4 reached end of life last year, so at the same time it's worrying that more than 25% of projects are still using it! Let's hope to see this number decline soon.

This data beautifully visualizes the division within the PHP community: one part is keeping up with modern PHP, while another one stays helplessly behind. I know there are many reasons to stay behind — often driven by business requirements and constraints — but it's crucial to realise that a lot of PHP projects are in fact running insecure and slow versions in production because of it.

Moving on to the all-time overview chart, here you can see the evolution of version usage across time:

All time evolution

Like I said: the decline of 7.4 is going too slow to my liking. Compare it to the much steeper decline of PHP 5.5 back in 2015 when PHP 7.0 was released: I would have liked to see the same happen with PHP 7.4 and have people move to PHP 8.0, but unfortunately that's not the case.

I feel like I'm repeating myself every year, but I really hope that people upgrade their projects sooner in the future. I'm curious to learn how this part of the PHP community can be helped. I feel that tools like Rector to automate upgrades have so much potential, if only people started using it.

# Required versions

Next, I used Nikita's popular package analyzer to download the 1000 most popular composer packages. I used a little script to get their minimum required version. Here are the results:

Version 2021-07 2022-01 2022-07 2023-01
8.2 - - - -
8.1 - - 125 129
8.0 117 160 94 103
7.4 56 69 86 98
7.3 133 116 104 106
7.2 142 133 130 144
7.1 182 190 153 159
7.0 31 29 29 30
5.6 61 49 42 43
5.5 43 42 35 37
5.4 41 43 40 40
5.3 97 83 77 78
5.2 12 10 10 10

There are two important notes to make here.

  1. This tables shows the minimum required version. It makes sense that none of the 1000 packages already supports PHP 8.2, since it's been only here for a month.
  2. If you count the numbers, you'll notice there are some differences between each year. Not every package lists a version, so not all 1000 packages can be parsed.

Instead of comparing absolute numbers, it's best to plot this data into a chart for a relative comparison, so that we can see changes over time:

Minimal PHP requirement over time

You can see there's a slight increase in PHP 7.* requirements. It's a good evolution, but still very slow compared to how fast PHP is moving forward.

In my opinion, package authors should push more to require only supported PHP versions. I think it's the only way for PHP to keep moving forward at a decent rate, and for the community to keep up. On top of that: yearly upgrades are much easier to do than to stay on, for example, PHP 7.4 and try to make the jump directly to PHP 8.2.

This blog post was sponsored by Private Packagist - the private Composer repository from the creators and maintainers of Composer & Packagist.

In closing, if you take one thing away from this post, I hope it's that it's time to upgrade to at least PHP 8.1, preferably PHP 8.2. It's not as difficult as you might think, and it's definitely worth your time.

What are your thoughts on these stats? Are you using PHP 8.2? Let me know your thoughts on Twitter and subscribe to my newsletter if you want to be kept up-to-date about these posts!

Noticed a tpyo? You can submit a PR to fix it. If you want to stay up to date about what's happening on this blog, you can follow me on Twitter or subscribe to my newsletter: