composer php

PHP recently dropped support for PHP 7.2, and today only supported versions are PHP 7.3, 7.4 and 8.0, but some applications are still running very old versions of PHP. According to PHP versions stats from packagist, we can see that over the last six years support for new versions quickly increase, but takes much more time to disappear. Unsupported versions remain there with their insecurities and bugs, mostly unmaintained and this is very bad for the web.

PHP 8

Why not PHP 8 ?

So if you are using Composer, here is a quick tips to see if your code is ready for PHP8, simply run :

$ composer why-not php:8

The result will be the list of packages that your application depends on them, but that don’t support PHP8 yet. I run this on a random old applications :

bitgrave/barcode-bundle          9999999-dev  requires  php (^5.5 || ^5.6 || ^7.0)  
cache/adapter-bundle             1.3.1        requires  php (^5.6 || ^7.0)          
cache/adapter-common             1.1.0        requires  php (^5.6 || ^7.0)          
cache/array-adapter              1.0.1        requires  php (^5.6 || ^7.0)          
cache/cache-bundle               1.1.0        requires  php (^5.6 || ^7.0)          
cache/doctrine-adapter           1.0.0        requires  php (^5.6 || ^7.0)          
cache/hierarchical-cache         1.0.0        requires  php (^5.6 || ^7.0)          
cache/memcached-adapter          1.0.0        requires  php (^5.6 || ^7.0)          
cache/namespaced-cache           1.0.0        requires  php (^5.6 || ^7.0)          
cache/psr-6-doctrine-bridge      3.0.1        requires  php (^5.6 || ^7.0)          
cache/session-handler            1.0.0        requires  php (^5.6 || ^7.0)          
cache/taggable-cache             1.0.0        requires  php (^5.6 || ^7.0)          
dmishh/settings-bundle           3.0.x-dev    requires  php (^7.2)                  
doctrine/doctrine-cache-bundle   1.4.0        requires  php (^7.1)                  
elasticsearch/elasticsearch      v5.5.0       requires  php (^5.6|^7.0)             
floriansemm/solr-bundle          v1.7.1       requires  php (^7.0)                  
gedmo/doctrine-extensions        v3.0.0       requires  php (^7.2)                  
knplabs/knp-menu-bundle          v2.3.0       requires  php (^7.1)                  
liip/imagine-bundle              2.3.1        requires  php (^7.1)                  
oneup/flysystem-bundle           3.5.0        requires  php (^7.0)                  
paragonie/random_compat          v9.99.99     requires  php (^7)                    
solarium/solarium                4.2.0        requires  php (^7.0)                  
stof/doctrine-extensions-bundle  v1.5.0       requires  php (^7.1.3) 

You are probably running an older version of the package and there are already some missing updates, so make sure to check outdated packages first using :

$ composer outdated

Which is basically an alias to composer show -lo. Finally you can update/upgrade your packages until why-not command tells you that your dependencies are ready to upgrade to PHP8. Of course make sure to check PHP8 incompatibilities list that should be tested for before switching PHP versions in production environments.

Also check composer documentation for a complete list of commands.

LEAVE A REPLY

Please enter your comment!
Please enter your name here