作者:mindylee | 来源:互联网 | 2023-09-25 18:09
我正在使用packagist和firegento上的包vendorName/moduleName(Magento扩展).在我的composer.json文件中,我有:
我正在使用packagist和firegento上的包vendorName / moduleName(Magento扩展).
在我的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
},
但是,作曲家将不再在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.
这意味着如果我在composer.json中定义firegento repo,那么composer将在packagist之前加载firegre中的包vendorName / moduleName.我以为这是相反的行为;我错了.
另一个有用的评论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.