/flags/composer/composer-ignore-platform-req
composer install --ignore-platform-req=php: skip one PHP or extension check
- tool
- Composer
- command
- composer install, composer update, composer require
- flag
- --ignore-platform-req=NAME, --ignore-platform-reqs
- default
- off (PHP version, extensions and libraries are checked)
Composer checks platform requirements before installing: the PHP version (php), extensions (ext-intl, ext-gd) and system libraries (lib-*) that packages declare. When the machine running Composer does not satisfy them, the install stops with "Your requirements could not be resolved to an installable set of packages" or "Your lock file does not contain a compatible set of packages". --ignore-platform-req=ext-intl skips one of those checks; --ignore-platform-reqs (plural) skips all of them.
Common forms
composer install --ignore-platform-req=ext-intl # one extension
composer install --ignore-platform-req=ext-* # every extension (wildcard)
composer install --ignore-platform-req=php+ # only the upper bound of php
composer install --ignore-platform-reqs # everything (last resort)
COMPOSER_IGNORE_PLATFORM_REQ=ext-intl composer install # environment variable formOptions compared
| Option | Ignores | Typical case |
|---|---|---|
| --ignore-platform-req=ext-NAME | One extension | Build container lacks an extension the runtime image has |
| --ignore-platform-req=php | The PHP version constraint | Testing a newer PHP before packages declare support |
| --ignore-platform-req=php+ | Only the upper bound of php | Package says ^7 but works on PHP 8 |
| --ignore-platform-req=ext-* | All extensions | Composer-only image used to fill vendor/ |
| --ignore-platform-reqs | PHP, extensions and libraries | Avoid; hides real incompatibilities |
| config.platform in composer.json | Nothing: pretends a fixed platform | Build machine differs from production |
Better: declare the target platform
{
"config": {
"platform": {
"php": "8.3.0",
"ext-intl": "1.0"
}
}
}With config.platform, Composer resolves packages for PHP 8.3 with intl on every machine, so the lock file fits production even when developers run another PHP version. Nothing is ignored; Composer simply knows what to target.
Pitfalls
- Ignoring a requirement does not make the code work. A package that needs
ext-intlfails at runtime, typically with a missing class or function error, if the extension is really missing. - Since Composer 2,
vendor/composer/platform_check.phpchecks PHP and extensions at runtime and stops with Composer detected issues in your platform when they are missing, even if you installed with the flag. - Missing
ziporunzipis not a platform requirement but a Composer download problem: see The zip extension and unzip/7z commands are both missing. - Resolution errors with other causes (conflicting versions) are explained in Your requirements could not be resolved.
FAQ
What is the difference between --ignore-platform-req and --ignore-platform-reqs?
--ignore-platform-reqs (plural) ignores every platform requirement: PHP, all extensions and libraries. --ignore-platform-req=NAME (singular, repeatable, wildcards allowed) ignores only the named one, which keeps the other checks working.
What does the + in --ignore-platform-req=php+ mean?
It ignores only the upper bound. A package requiring php ^7 can then be installed on PHP 8, but installing on PHP 5.6 still fails because the lower bound is still checked.
Is config.platform better than the flag?
When the build machine differs from production, yes. Setting config.platform.php to the production version makes Composer resolve for that version on every machine, without ignoring anything.