lesssugar
lesssugar

Reputation: 16181

Composer: prevent updating packages that require higher PHP version

I'm using the doctrine/dbal (v2.4.*) package in my PHP project. My production server runs PHP v5.6.

I ran composer update this morning which updated my composer.lock file. Now, when I'm deploying to production, I see this:

 Problem 1
    - Installation request for doctrine/inflector v1.2.0 -> satisfiable by doctrine/inflector[v1.2.0].
    - doctrine/inflector v1.2.0 requires php ^7.0 -> your PHP version (5.6.14) does not satisfy that requirement.
  Problem 2
    - doctrine/inflector v1.2.0 requires php ^7.0 -> your PHP version (5.6.14) does not satisfy that requirement.
    - doctrine/common v2.4.3 requires doctrine/inflector 1.* -> satisfiable by doctrine/inflector[v1.2.0].
    - Installation request for doctrine/common v2.4.3 -> satisfiable by doctrine/common[v2.4.3].

Specifically these:

doctrine/common v2.4.3 requires doctrine/inflector 1.* -> satisfiable by doctrine/inflector[v1.2.0].

doctrine/inflector v1.2.0 requires php ^7.0 -> your PHP version (5.6.14) does not satisfy that requirement

This means, that even if dbal is old, it requires the newest common, and common requires the newest inflector package. Problem is that inflector started depending on PHP7 to run.

Is there any way in Composer to limit updating of the packages to those supported by specific PHP version? Like saying: "Please update what you can, but only if the server's PHP version is sufficient."

Upvotes: 2

Views: 3497

Answers (2)

Ayman Elshehawy
Ayman Elshehawy

Reputation: 2964

  • Remove composer.lock file
  • Run composer install

Upvotes: 0

xabbuh
xabbuh

Reputation: 5881

Use the platform option in your composer.json file to define the PHP version your production environment is using like this:

{
    "config": {
        "platform": {
            "php": "5.6.14"
        }
    }
}

see https://getcomposer.org/doc/06-config.md#platform

Upvotes: 9

Related Questions