Reputation: 727
Does Composer provide a way to require a particular version of a package depending on the installed PHP version?
E.g. if PHP 7.3 is the installed PHP version when I run composer install
then PHPUnit version 8 should be installed. If I changed my environment to use PHP 5.6 and ran composer install
then PHPUnit 5 should be installed.
Upvotes: 0
Views: 62
Reputation: 2310
Not directly, no, but you can use e.g. ^5.0 || ^8.0
constraint which will make sure that the highest available version of PHPUnit compatible with your PHP version will be installed.
In this example, since PHPUnit 8.0 cannot be installed on anything less than PHP 7.2, Composer will simply install latest PHPUnit 5.x when using PHP 5.6. When using PHP 7.2 or later, Composer will install the latest PHPUnit 8.x.
Upvotes: 1