How to install Composer packages ignoring PHP version requirements
A new feature in Composer v2 allows you to selectively ignore platform requirements.
composer install --ignore-platform-req=php
Composer already has a
--ignore-platform-reqs option (notice the s in
reqs), but it ignores all platform requirements, including PHP version, extensions (
--ignore-platform-req option can be used to set specific requirements that Composer can ignore.
Ignore multiple platform requirements
You can specify one or more platform requirements to ignore by simply using the option multiple times.
For example, to ignore the PHP version and
ext-zip, but enforce all other platform requirements, you can use the command like this:
composer install --ignore-platform-req=php --ignore-platform-req=ext-zip
Install Composer packages on unreleased PHP versions
A common use-case of
ignore-platform-req option would be to test PHP packages in unreleased PHP versions, or
dev builds of PHP.
Libraries such as PHPUnit come with rather strict PHP version constraint in their
composer.json file, which prevents them the libraries from being installed in
dev versions of PHP.
Instead of using
ignore-platform-reqs, which would ignore all platform requirements such as extensions (which might be required for the package to function), you can use
ignore-platform-req option to selectively specify platform requirements you intentionally ignore.