composer 如何处理同一个包的多个版本? [英] How does composer handle multiple versions of the same package?
问题描述
这可能(应该)在某处之前被问过,但我似乎找不到答案.如果有人提供链接,我可以删除此帖子!:
This may (should) have been asked before somewhere but I can't seem to find an answer. If someone provides a link I can delete this post!:
只是想了解 Composer 的一些(可能也适用于其他包管理器)的功能.
Just trying to get my head around some of composer's (probably applies to other package managers too) functionality.
基本上我只想知道 composer 在以下场景中做了什么:
Basically I just want to know what composer does in the following scenarios:
1.
我的主项目有一个依赖项:
My main project has a dependency:
"guzzlehttp/guzzle": "5.0.*",
我的外部包依赖于
"guzzlehttp/guzzle": "5.0.*",
composer 是否会安装 guzzlehttp/guzzle 一次,因为它知道它只需要一次?
Does composer install guzzlehttp/guzzle one time because it knows it only needs it once?
2.相同的场景,但将来如果有人更新要使用的主项目:
2. Same scenario but in the future if someone updates the main project to use:
"guzzlehttp/guzzle": "6.0.*",
composer 现在会安装 2 个版本的 guzzle(5 和 6)(我认为这是它应该做的),还是会采用最高版本(即 6)?此外,如果有 2 个版本,这是否会导致任何冲突,因为命名空间可能相同?
Will composer now install 2 versions of guzzle (5 and 6) (I presume this is what it should do), or will it take the highest version (i.e. 6)? Also if there are 2 versions will this cause any conflicts because namespaces might be the same?
谢谢
推荐答案
到问题 1
是的 Composer 只能安装每个扩展/包的一个版本.
To question 1
Yes Composer can only install one version of each extension/package.
因为答案 1:Composer 会认为您的主项目和外部包不兼容.
Because of answer 1: Composer would consider your main project and the external package as incompatible.
在这种情况下你可以
- 在您的主要项目中也使用第 5 版.
- 如果兼容,也请外部软件包所有者升级到版本 6.
- fork 外部包并使其与版本 6 自己兼容
这篇关于composer 如何处理同一个包的多个版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!