Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
517 views
in Technique[技术] by (71.8m points)

php - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...