7

I would like to run composer using php 7 installed inside a docker container, but the final software will run on php 5 since thats what the production server is running.

I don't see any correlation between installing software for php 5 and using php 7 cli to run composer, yet there appears to be a connection.

How can I tell composer that it doesn't matter what version I run composer with, what matters is the packages that it installs.

Christopher Thomas
  • 4,424
  • 4
  • 34
  • 49
  • This question is related to yours https://stackoverflow.com/questions/26277151/force-composer-to-require-php-version-between-version-x-and-version-y – Nima Aug 23 '17 at 19:10

2 Answers2

12

The correct solution it seems is to add the following

"config": {
    "platform": {
        "php": "5.6.17"
    }
}

to your composer file, then it will use that as the "version" of php you want to respect.

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

localheinz
  • 9,179
  • 2
  • 33
  • 44
Christopher Thomas
  • 4,424
  • 4
  • 34
  • 49
-2

Your composer.json file tells composer what version of the software to download. What versions of PHP that software supports is up to the software. If the package you're trying to download stopped supporting PHP 5 in version 4, for example, you would require version 3, like this "3.*" or "3.9" or whatever your specific requirement is.

"require": {
    "some/package": "3.*"
}

https://getcomposer.org/doc/01-basic-usage.md#package-version-constraints

You can "require" a certain version of PHP using platform packages, but that doesn't download anything, just checks. As you're developing on 7 and releasing on 5, that's not what you want.

  • 1
    hmmm, this only say to limit the versions to what you require, it doesnt say what version of php I would like to limit my installation to – Christopher Thomas Aug 23 '17 at 19:10