Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force composer to require PHP Version between Version X and Version Y

we have a mix of different PHP versions running on your servers (max 5.3.5) and development machines (max 5.5.9).

Now we ran into the problem that we did a "composer update" to get the latest Version of some external Bundles. Since your composer.json looks like

"require": {         "php": ">=5.3.3",         .....     }, 

we get some Bundles that required PHP 5.5. No problem on our dev machines, but on the server :(

Is there any possibility to tell composer to require a PHP version between 5.3.3 and 5.3.5? Or a max available Version?

I tried

"require": {         "php": ">=5.3.3, <=5.3.5",             .....         }, 

and

"require": {             "php": "<=5.3.5",                 .....             }, 

but both didn't work out. I get a "The requested package php could not be found in any version, there may be a typo in the package name." Error.

Any Ideas? Thanks in advance

like image 325
Fabian Avatar asked Oct 09 '14 11:10

Fabian


People also ask

How do I update composer to a specific version?

To change to version one run the self-update command and pass in the --1 flag. This will change composer to version one and now you can install your dependencies. Once you have installed your dependencies, now you can run the same command and pass in --2 as the flag and this will switch back to composer version 2.

How do I downgrade my composer PHP version?

First, grab this URL: https://composer.github.io/pubkeys.html . From there, the terminal will prompt you for which key you need to enter. Once done, you should be able to complete the downgrade process.

What is minimum stability in composer?

An alternative is to set your minimum-stability to dev, but tell composer you want to use stable whenever possible: "minimum-stability": "dev", "prefer-stable" : true. This basically means it will always use stable UNLESS there is no way to install a stable dependency, and therefore use dev.


1 Answers

Since the config parameter in composer.json is available. You could something like this:

{     "name": ".../...",     "config": {         "platform": {             "php": "5.3.5"         }     },     "require": {         ...     } }  

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

like image 96
NuSphere Avatar answered Sep 28 '22 05:09

NuSphere