W3docs

Tell Composer to use Different PHP Version

To use a specific version of PHP with Composer, you can specify the version you want to use in the config section of your composer.json file.

To use a specific version of PHP with Composer, you can specify the version you want to use in the config section of your composer.json file. For example:

How to make Composer use a different PHP version?

{
    "name": "example/project",
    "require": {},
    "config": {
        "platform": {
            "php": "7.4"
        }
    }
}
Info

Watch a video course: Learn object oriented PHP

Alternatively, you can specify the PHP version you want to use on the command line when you run Composer. For example:

composer config platform.php 7.4