Can I override a composer.json dependency to remove it?

送分小仙女□ 提交于 2019-12-23 15:53:08

问题


I know it's possible to override a composer dependency using:

"some/module": "1.0.0 as 2.0.0",

But is it possible to entirely remove a dependency that one of my dependencies requires?

The issue is that I am requiring "cwp/cwp-recipe-basic": "1.1.0", which can be found here. That package is simply another list of dependencies, however I do not want one of those dependencies.

Is there any way of telling composer to ignore that one dependency?

E.g.

"cwp/cwp-recipe-basic": "1.1.0",
"silverstripe/fulltextsearch": " as 1.1.0"

回答1:


I guess you can't. But if it is only a list of dependencies why don't you just copy the list except the ones you don't need and paste them into your composer.json?

Another approach could be if it is a long list to fork cwp/cwp-recipe-basic and remove the dependencies you don't need from that list and then require the fork in your project.




回答2:


You can use replace setting in your composer.json:

"replace": {
    "silverstripe/fulltextsearch": "1.1.0"
}

Composer will act as this package is already available and will not install it. Note that you will not able to use it, since it is not actually installed.



来源:https://stackoverflow.com/questions/30859285/can-i-override-a-composer-json-dependency-to-remove-it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!