composer:有没有一种方法可以指定软件包存储库的优先顺序? [英] composer : is there a way to specify a preference order for package repositories?

查看:115
本文介绍了composer:有没有一种方法可以指定软件包存储库的优先顺序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 packagist 上的软件包vendorName/moduleName(Magento扩展名) href ="http://packages.firegento.com/" rel ="noreferrer"> firegento .

I am working with a package vendorName/moduleName (a Magento extension) that is present on packagist and on firegento.

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

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

由于下载了Composer,并且已预先配置为使用packagist.org ,所以vendorName/moduleName是从packagist加载的

我想强制从firegento加载vendorName/moduleName.

I would like to force vendorName/moduleName to be loaded from firegento.

我尝试添加:

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

但是,然后,作曲家将不再在packagist中进行搜索:这不是我想要的.(因为packagist中也有有用的软件包...)

but then, composer will no more search in packagist : that's not what I want.(as there are usefull packages in packagist too...)

我想我可以使用

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

以我喜欢的顺序添加存储库(我不确定它是否起作用...).

to add repositories in my prefered order (I'm not sure it works...).

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

Is there a better/simpler way to achieve my purpose ? I would prefer editing the composer.json more than running global config commands but it's maybe not possible.

推荐答案

嗯,

我想我在此处找到了答案:

最后,仅根据存储库定义的定义顺序对其进行评估.根据定义,Packagist在内部被添加为最后一个(尽管您可以将其禁用),以确保在解析程序设置允许的情况下始终首选本地副本.

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存储库,则作曲家将在packagist之前的firegento中加载软件包vendorName/moduleName.我认为这是相反的行为.我错了.

That means that if I define the firegento repo in my composer.json, then composer will load the package vendorName/moduleName in firegento before packagist. I thought it was the opposite behaviour; I was wrong.

另一条有用的评论此处:

存储库定义的顺序很重要.但是无论如何,composer仍然会搜索所有存储库,因为稍后定义的存储库可能具有您需要的软件包的较新版本.

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.

这篇关于composer:有没有一种方法可以指定软件包存储库的优先顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆