如何使用相互依赖的作曲家同时安装 2 个 Symfony 包
Posted
技术标签:
【中文标题】如何使用相互依赖的作曲家同时安装 2 个 Symfony 包【英文标题】:How to install 2 Symfony bundles at the same time with composer which depend on each other 【发布时间】:2017-05-14 19:47:50 【问题描述】:我想将 friendsofsymfony/elastica-bundle
从 3.1.*
升级到 dev-master
。
您可以在下面看到我当前的 composer.json 设置:
"require":
"php": ">=5.3.9",
"symfony/symfony": "2.8.*",
"doctrine/orm": "^2.4.8",
"doctrine/doctrine-bundle": "~1.4",
...
"friendsofsymfony/elastica-bundle": "3.1.*"
,
问题是当我删除行 friendsofsymfony/elastica-bundle
然后运行 composer require fiendsofsymfony/elastica-bundle "dev-master"
时:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for friendsofsymfony/elastica-bundle dev-master -> satisfiable by friendsofsymfony/elastica-bundle[dev-master].
- friendsofsymfony/elastica-bundle dev-master requires ruflin/elastica 3.2.* -> satisfiable by ruflin/elastica[3.2, 3.2.1, 3.2.2, 3.2.3] but these conflict with your requirements or minimum-stability.
然后我运行composer require ruflin/elastica "3.2.*"
并得到了这个:
您的需求无法解析为一组可安装的软件包。
Problem 1
- The requested package friendsofsymfony/elastica-bundle (locked at 3.1.8, required as dev-master) is satisfiable by friendsofsymfony/elastica-bundle[3.1.8] but these conflict with your requirements or minimum-stability.
所以我的问题是我需要安装ruflin/elastica
才能升级friendsofsymfony/elastica-bundle
但我还需要升级friendsofsymfony/elastica-bundle
才能安装ruflin/elastica
我怎样才能正确地做到这一点?
谢谢
【问题讨论】:
@Purple Hexagon 的答案是正确的,其他方法在这里回答:***.com/questions/16739998/… 【参考方案1】:不要认为在运行 require 之前确实需要从 composer.json 中删除旧版本。但要回答你的问题……在我看来,你有两种选择。
1:尝试在一个命令中安装两个新软件包
composer require ruflin/elastica:3.2.* friendsofsymfony/elastica-bundle:dev-master
2:只需手动编辑您的 composer.json,然后运行 composer update
"require":
"php": ">=5.3.9",
"symfony/symfony": "2.8.*",
"doctrine/orm": "^2.4.8",
"doctrine/doctrine-bundle": "~1.4",
...
"friendsofsymfony/elastica-bundle": "dev-master",
"ruflin/elastica": "3.2.*"
,
【讨论】:
谢谢,第二种方法很有效,我不知道为什么我以前没有这样做。以上是关于如何使用相互依赖的作曲家同时安装 2 个 Symfony 包的主要内容,如果未能解决你的问题,请参考以下文章
GCP apache气流,如何从私有存储库安装Python依赖项