如何使用相互依赖的 composer 同时安装 2 个 Symfony 包

How to install 2 Symfony bundles at the same time with composer which depend on each other

我想将 friendsofsymfony/elastica-bundle3.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

我怎样才能正确地做到这一点?

谢谢

不要认为在 运行 提出要求之前,您真的需要从 composer.json 中删除旧版本。但是要回答你的问题......我认为你有两种选择。

1:尝试在一个命令中安装两个新包

composer require ruflin/elastica:3.2.* friendsofsymfony/elastica-bundle:dev-master

2:只需手动编辑您的 composer.json 然后 运行 作曲家更新

"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.*"

},