运行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.
相关文章