PHP Versions Stats - 2018.2 Edition

It's stats o'clock! See 2014, 2015, 2016.1, 2016.2, 2017.1, 2017.2 and 2018.1 for previous similar posts.

A quick note on methodology, because all these stats are imperfect as they just sample some subset of the PHP user base. I look in the packagist.org logs of the last month for Composer installs done by someone. Composer sends the PHP version it is running with in its User-Agent header, so I can use that to see which PHP versions people are using Composer with.

PHP usage statistics

November 2018 (+/- diff from May 2018)

All versions Grouped
PHP 7.2.10 9.57% PHP 7.2 32.63% (+12.45)
PHP 7.0.32 8.58% PHP 7.1 31.70% (-3.32)
PHP 7.2.11 7.92% PHP 7.0 19.40% (-3.62)
PHP 5.6.38 4.67% PHP 5.6 11.64% (-4.84)
PHP 7.1.22 4.09% PHP 5.5 2.38% (-1.12)
PHP 7.1.23 3.73% PHP 5.4 0.94% (-0.1)

A few observations: PHP 7.2 passed 7.1 so we get back to a sensible order with the most recent versions seeing the most use. We are now at 84% of people using PHP 7+ and 96% using a PHP version that is still maintained for security updates. PHP 5.6 and 7.0 will reach end of life by late 2018 though so that's 31% (down 9% in the last six months) of users who are in need of an upgrade if we want to keep these numbers up!

Here is the aggregate chart covering all my blog posts and the last five years.

PHP requirements in Packages

The second dataset is which versions are required by the PHP packages present on packagist. I only check the require statement in their current master version to see what the latest requirement is, and the dataset only includes packages that had commits in the last year to exclude all EOL'd projects as they don't update their requirements.

PHP Requirements - Recent Master - November 2018 (+/- diff from Recent Master May 2018)

5.21.11% (-0.05)
5.313.77% (-2.13)
5.414.4% (-2.19)
5.513.42% (-2.1)
5.617.66% (-1.91)
7.020.27% (0.8)
7.117.17% (6.02)
7.22.19% (1.55)
7.30.01% (0.01)

We see a good push of libraries targetting PHP 7.1 which is certainly helped by a few big players like Doctrine and Symfony having made that move. If you are releasing a new major version of a library today I would say require PHP 7.1 and enjoy!