I would like my composer.json to tell composer to install 1 version of a library if the system runs php7.x and another if the system runs on php8.x
The reason is that the 1.x versions of the library are compatible with php7 and 2.x versions only with php8. Like so:
if:{php: ^7, require:{mylib:^1.0}}
else:{php: ^8, require{mylib:^2.0}}
That would be great.
Some of our customers can not switch their servers to php8 so fast for various reasons but we would like to move on.
"require": {"mylib": "*"}
, and "mylib/composer.json" must contain information about PHP compatibility.*
is not - you'll get in a mess if the library author releases version 3 with changes that aren't compatible with your code. Much better to always list the versions you've actually confirmed will work.