2

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."

7
  • can you use inflector 1.1 instead? or go to common 2.7.3 or you could go to dbal 2.5.13
    – cmorrissey
    Commented Aug 17, 2017 at 15:40
  • You mean that I should require directly not only doctrine/dbal but also common and inflector? Does this make sense if dbal already requires them?
    – lesssugar
    Commented Aug 17, 2017 at 15:43
  • you can require dbal but just drop the version to 2.5.13
    – cmorrissey
    Commented Aug 17, 2017 at 15:43
  • The dbal version I'm using is 2.4.*. So, it's old. But as it requires newest packages internally, it doesn't matter how old it is.
    – lesssugar
    Commented Aug 17, 2017 at 15:45
  • try composer require doctrine/inflector:1.1.0
    – cmorrissey
    Commented Aug 17, 2017 at 15:56

2 Answers 2

9

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

3
  • "Lets you fake platform packages (PHP and extensions) so that you can emulate a production env or define your target platform in the config". Sounds like something not exactly designed to be used on production. I guess I won't know for sure until I try.
    – lesssugar
    Commented Aug 20, 2017 at 13:21
  • As an alternative, run composer require, composer update, and composer install only in environments as close as possible to your production systems.
    – localheinz
    Commented Aug 22, 2017 at 5:44
  • 1
    This answer is brilliant... Thanks
    – user4258584
    Commented Aug 21, 2019 at 8:01
0
  • Remove composer.lock file
  • Run composer install

Not the answer you're looking for? Browse other questions tagged or ask your own question.