composer存储库优先级问题

Posted ljl890705

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了composer存储库优先级问题相关的知识,希望对你有一定的参考价值。

composer存储库repositories可以有多个,默认是按照顺序。

但有时可能会出现因为优先级问题导致的包无法安装,例如想安装一个优先级比较低的源里的包,但是这个包在更高优先级的源里也存在,就会报出如下异常:

Problem 1
- Root composer.json requires xxx/yyy v1.2.3-dev, it is satisfiable by xxx/yyy[v1.2.3-dev] from composer repo (https://a.b.c) but xxx/yyy[v1.1.0, …, v1.2.2] from composer repo (https://z.y.x) has higher repository priority. The packages with higher priority do not match your constraint and are therefore not installable. See https://getcomposer.org/repoprio for details and assistance.

此时,可以按照以下方法解决:

1.在repositories中的https://z.y.x下加入配置"exclude": ["xxx/yyy"],表示忽略这个存储库中的xxx/yyy包。
2.在https://a.b.c下加入配置"only": ["soda-m/saluzi"],表示在这个存储库中只加载xxx/yyy包。

在某些情况下,只做第一步就可以,跳过高优先级的源就能实现目标。

以上是关于composer存储库优先级问题的主要内容,如果未能解决你的问题,请参考以下文章

composer存储库优先级问题

作曲家:找不到命令

Composer - 添加没有 composer.json 的 git 存储库

如何在 GitHub 存储库中包含 Composer

如何使用 composer 安装部分 git 存储库?

我的 composer.json 的一个存储库现在是空的或私有的 我仍然想使用这个 composer.json 我如何添加新的存储库