微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐