是否有可能在Composer配置中忽略子依赖项? [英] It's possible ignore child dependency in Composer config?

查看:267
本文介绍了是否有可能在Composer配置中忽略子依赖项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行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的替换属性下载的软件包: 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.

这可以帮助您忽略您确定不需要的软件包,但这有点怪异。因此,请注意某些事情(例如测试)可能会中断。
更好的方法是从原始软件包的维护者那里请求补丁,以使要求成为可选的(通过 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).

编辑:

示例禁用对<$ c $的要求c> zendframework / zend-mail :

{
    "name": "my_app",
    "require": {
        "some/package": "0.0.0"
    },
    "replace": {
        "zendframework/zend-mail": "*"
    }
}

这篇关于是否有可能在Composer配置中忽略子依赖项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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