是否可以忽略 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
属性忽略要下载的包:https://getcomposer.org/doc/04-schema.md#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.
这可以帮助您忽略您确定不需要的包,但它有点 hacky.所以请注意某些事情(如测试)可能会中断.更好的方法是向原始包的维护者请求补丁以使要求成为可选(通过 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
的要求:
{
"name": "my_app",
"require": {
"some/package": "0.0.0"
},
"replace": {
"zendframework/zend-mail": "*"
}
}
这篇关于是否可以忽略 Composer 配置中的子依赖项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!