Ignore Platform Requirements in Composer

Ignore Platform Requirements in Composer

Composer verifies that the current environment satisfies the PHP version and extension requirements declared by project dependencies before installing packages. If the installed PHP version or a required extension does not match the constraints defined by a package, the installation process stops with an error. However, there are situations where these checks can become an obstacle, such as when reviewing or analyzing code in the integrated development environment (IDE) without actually running the project. This tutorial explains how to ignore platform requirements in Composer.

For example, the following message shows that the current PHP version does not satisfy the package requirements:

Problem 1
  - symfony/cache is locked to version v8.1.1 and an update of this package was not requested.
  - symfony/cache v8.1.1 requires php >=8.4.1 -> your php version (8.2.32) does not satisfy that requirement.

In cases where these checks need to be bypassed, Composer provides options for ignoring platform requirements.

To skip all platform requirement checks during installation, execute:

composer install --ignore-platform-reqs

To ignore only the PHP version requirement while continuing to validate extensions, use:

composer install --ignore-platform-req=php

To bypass the requirement for a specific PHP extension, specify its name:

composer install --ignore-platform-req=ext-openssl

Multiple platform requirements can also be ignored in a single command:

composer install --ignore-platform-req=ext-openssl --ignore-platform-req=php

These options are useful for development environments, testing, or temporary compatibility workarounds. However, ignoring platform requirements may result in runtime errors if the project depends on features that are unavailable in the current environment.

Leave a Comment

Cancel reply

Your email address will not be published.