Use php 7 to run composer but install packages for php 5

I would like to launch the composer using php 7 installed inside the docker container, but the final software will be running on php 5, as this means that the production server is working.

I don't see any correlation between installing php 5 software and using php 7 cli to start the composer, but there seems to be a connection.

How can I tell the composer that no matter which version I run the composer in, the packages that it installs are important.

+5
source share
2 answers

The correct solution seems to be as follows:

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

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

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

+6
source

Your composer.json file tells the composer which version of the software to download. Which versions of PHP that the software supports are software dependent. If the package you are trying to download has stopped supporting PHP 5 in version 4, for example, you will need version 3, for example, "3. *" or "3.9" or whatever you require from your specific requirement.

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

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

You can โ€œrequireโ€ a specific version of PHP using the platform packages, but it doesnโ€™t load anything, it just checks. Since you are developing at 7 and freed at 5, this is not what you want.

-1
source

Source: https://habr.com/ru/post/1271166/


All Articles