php – composer:有没有办法为包存储库指定首选项顺序?

我正在使用packagistfiregento上的包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.

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...