Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to always use ignore-platform-reqs flag when running composer?

On my local machine, I have php v7.0.3. A project of mine has a dependency on php v5.5.

So as expected, a simple run of composer install crashes:

Your requirements could not be resolved to an installable set of packages.    Problem 1     - This package requires php ~5.5 but your PHP version (7.0.3) does not satisfy that requirement. 

I know I can ignore the platform via:

composer install --ignore-platform-reqs 

yet I often forget to add the flag. Yet since the application runs inside a docker container, a mismatching php can install the dependencies just as fine.

So I am wondering if there is a way to make my local composer always assume --ignore-platform-reqs in order to not having to type it.

I like to avoid setting an alias and have it work on composer config level.

like image 769
k0pernikus Avatar asked Feb 08 '16 15:02

k0pernikus


People also ask

What is ignore platform reqs?

When the versions don't match up, composer will not install your required packagist packages. But if you add the --ignore-platform-reqs option when you run composer update , it will gracefully ignore these restrictions.

How do I update composer Phar?

update / u# In order to get the latest versions of the dependencies and to update the composer. lock file, you should use the update command. This command is also aliased as upgrade as it does the same as upgrade does if you are thinking of apt-get or similar package managers.

How do I check if Composer is installed?

You can check your installed composer version using a command composer -v at the current path. Such as: composer -v.


1 Answers

It's recommended to fake php version, rather than ignore platform requirements. Add

"platform":{"php":"5.5"} 

to your ~/.composer/config.json or use composer config -g -e to edit it.

An example of sufficient config to fake php version:

{     "config": {         "platform":{             "php":"5.5"         }     } } 

It may have much more options though.

like image 164
Alex Blex Avatar answered Sep 24 '22 11:09

Alex Blex