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

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

So, as expected, the simple execution 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 that I can ignore the platform through:

 composer install --ignore-platform-reqs 

but I often forget to add a flag. However, since the application runs inside the docker container, non-matching php can install dependencies just as well.

So I'm wondering if there is a way to make my local composer always assume --ignore-platform-reqs so as not to type it.

I like to avoid setting an alias and working with it at the composer configuration level.

+5
source share
2 answers

A fake php version is recommended rather than ignoring platform requirements. Add

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

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

An example of a sufficient configuration to fake a php version:

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

He may have many more options.

+6
source

You can add alias composer="composer --ignore-platform-reqs" to your .bash_profile , but it will break commands that don't recognize this parameter (like composer outdated ).

Personally, I have:

 alias composer="composer --ignore-platform-reqs" alias composer_orig="/usr/local/bin/composer" 

Because most of the time I want --ignore-platform-reqs , but still I can use composer_orig every time I see

[Symfony \ Component \ Console \ Exception \ RuntimeException]

The parameter --ignore-platform-reqs does not exist.

+3
source

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


All Articles