是否可以忽略Composer配置中的子依赖项? [英] Is it possible to ignore child dependencies in Composer config?
问题描述
当我运行composer install时,它将安装我所有其他软件包的"require"和"require".
When I run composer install, it will install all my "require" and the "require" of the other package.
我的composer.json
My composer.json
{
"name": "my_app",
"require": {
"some/package": "0.0.0"
}
}
子"依赖项
{
"name": "some/package",
"require": {
"zendframework/zend-mail": "2.4.*@dev",
"soundasleep/html2text": "~0.2",
"mpdf/mpdf": "6.0.0",
"endroid/qrcode": "1.*@dev"
}
}
我知道有可能忽略php扩展名,但是这些第二个require软件包呢?
I know that it's possible ignore the php extensions, but what about these second require package?
推荐答案
您可以忽略要通过composer.json的 replace
属性下载的软件包:
You can ignore packages to be downloaded with the replace
property of your composer.json: https://getcomposer.org/doc/04-schema.md#replace
通过这种方式,您可以告诉作曲家自己处理或处理该软件包的内容.
That way you tell composer, that you take or took care of that package's content on your own.
这可以帮助您忽略您确定不需要的程序包,但这有点怪异.因此,请注意某些事情(例如测试)可能会中断.更好的方法是从原始软件包的维护者那里请求补丁,以使需求成为可选的(通过 suggest
属性).
This can help you to ignore a package your are sure you do not need, but it is kind of hacky. So be aware some things (like tests) might break.
A better approach would be to request a patch from the maintainer of the original package to make the requirements optional (via the suggest
property).
示例用于禁用" zendframework/zend-mail
的要求:
edit:
Example for "disabling" the requirement to zendframework/zend-mail
:
{
"name": "my_app",
"require": {
"some/package": "0.0.0"
},
"replace": {
"zendframework/zend-mail": "*"
}
}
这篇关于是否可以忽略Composer配置中的子依赖项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!