gpt4 book ai didi

php - Composer : is there a way to specify a preference order for package repositories?

转载 作者:可可西里 更新时间:2023-10-31 22:50:39 25 4
gpt4 key购买 nike

我正在使用 packagist 上的包 vendorName/moduleName(Magento 扩展)和 firegento .

在我的 composer.json 文件中,我有:

"require": {
....................,
...................,
"vendorName/moduleName":"*"
},
"repositories": [
......................,
....................,
{
"type": "composer",
"url": "https://packages.firegento.com"
}
],

作为Composer is downloaded pre-configured to use packagist.org , vendorName/moduleName 是从 packagist 加载的。

我想强制从 firegento 加载 vendorName/moduleName

我尝试添加:

"repositories": [
{
"packagist": false
},

但是,composer 将不再在 packagist 中搜索:这不是我想要的。(因为 packagist 中也有有用的包...)

我想我可以用

composer config --global --unset repositories.packagist

然后

composer config --global repositories.firegento composer https://packages.firegento.com
composer config --global repositories.packagist composer https://packagist.org

以我喜欢的顺序添加存储库(我不确定它是否有效...)。

是否有更好/更简单的方法来实现我的目的?与运行全局配置命令相比,我更喜欢编辑 composer.json 但这可能是不可能的。

最佳答案

嗯,

我想我找到了答案 here :

Repository candidates are, in the end, only evaluated by their order of definition. Packagist is internally added as the last one by definition (though you can disable that) to ensure local copies are always preferred, if allowed by resolver settings.

这意味着如果我定义 firegento我的 repo composer.json ,然后 composer 将加载包 vendorName/moduleNamefiregento之前 packagist .我认为这是相反的行为;我错了。

另一个有用的评论 here :

Order of repository definitions matters. But composer will still search through all repositories regardless, because it could be that a repository that is defined later has a more recent version available of the package you are requiring.

关于php - Composer : is there a way to specify a preference order for package repositories?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49190694/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com