I’ve learned the hard way that blindly using Composer’s
--ignore-platform-reqs can lead to issues like the downloading of package versions that are not compatible with your PHP version. I am on PHP 7.4 but packages using PHP 8 features were being downloaded, leading to this error:
syntax error, unexpected '|', expecting variable (T_VARIABLE)
It is safer to specify the platform requirement you would like to ignore using the
--ignore-platform-req option of Composer v2:
composer install --ignore-platform-req=ext-pcntl
I added a script to composer.json to ease this:
As seen above, to ignore multiple platform requirements you use the `–ignore-platform-req` multiple times.