It's stats o'clock! See 2014, 2015, 2016.1, 2016.2, 2017.1, 2017.2, 2018.1, 2018.2 and 2019.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. CI environments are excluded on a best-effort basis.

PHP usage statistics

November 2019 (+/- diff from May 2019)

All versions Grouped
PHP 7.3.11 11.12% PHP 7.3 35.24% (+19.89)
PHP 7.2.24 10.29% PHP 7.2 31.66% (-7.32)
PHP 7.3.12 6.94% PHP 7.1 15.27% (-10.32)
PHP 7.3.9 5.85% PHP 5.6 6.91% (-0.77)
PHP 5.6.40 4.89% PHP 7.0 6.04% (-3.39)
PHP 7.1.33 4.86% PHP 7.4 2.92% (+2.92)

A few observations: PHP 7.3 has grown very well and except for 7.4 (released Nov 28th) and 5.6 which is still holding on a bit more than it should, all versions are nicely ordered with the most recent being most used. With PHP 7.1 also reaching end of life a few days ago, the number of people using maintained PHP versions dropped to 70% (from 80%), a big drop but given the growth of 7.3 and 7.4 I think this should come back up very soon. PHP 5 usage across all versions is now around 9% (-1% from 6 months ago, we are definitely in long tail territory here).

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 2019 (+/- diff from Recent Master May 2019)

5.20.74% (-0.17)
5.39.62% (-1.54)
5.410.48% (-1.65)
5.59.3% (-1.68)
5.614.21% (-1.83)
7.017.88% (-1.3)
7.123.95% (+0.15)
7.211.8% (+6.39)
7.31.79% (+1.41)
7.40.23% (+0.22)

Back in May PHP 7.2 and 7.1 were gaining mostly, now we see PHP 7.2 as the main winner and 7.3 starting to pick up pace. The most required PHP version is now 7.1 which is EOL so time to move on!