运行composer时如何始终使用ignore-platform-reqs标志? [英] How to always use ignore-platform-reqs flag when running composer?

查看:29
本文介绍了运行composer时如何始终使用ignore-platform-reqs标志?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的本地机器上,我有 php v7.0.3.我的一个项目依赖php v5.5.

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

正如预期的那样,一个简单的 composer install 运行崩溃了:

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

但我经常忘记添加标志.然而,由于应用程序在 docker 容器内运行,不匹配的 php 可以同样好地安装依赖项.

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.

所以我想知道是否有办法让我的本地作曲家总是假设 --ignore-platform-reqs 以便不必输入它.

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.

推荐答案

推荐 fakephp 版本,而不是忽略平台要求.添加

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

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

到你的 ~/.composer/config.json 或使用 composer config -g -e 来编辑它.

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

一个足以伪造 php 版本的配置示例:

An example of sufficient config to fake php version:

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

不过它可能有更多选择.

It may have much more options though.

这篇关于运行composer时如何始终使用ignore-platform-reqs标志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆