Using a specific PHP version in production for installed composer packages.

When you are running a specific PHP version in production, you need to generate a "composer.lock" locally based on that.

To instruct Composer which PHP version you use in Production servers. You can run the following command.

composer config platform.php 7.2

Which will add a similar values to your composer.json file.

 "config": {
        "preferred-install": "dist",
        "sort-packages": true,
        "optimize-autoloader": true,
        "platform": {
            "php": "7.2"
        }
    },

Post inspired by this tweet by @nunomaduro

Sometimes you will find the need to ignore these platforms requirements, which can be done like this:

composer update phpunit/phpunit --ignore-platform-reqs

Victor Yoalli

This is me.