将 Symfony 从 2.8 升级到 3.1:"Your requirements could not be resolved to an installable set of packages."

Upgrading Symfony from 2.8 to 3.1: "Your requirements could not be resolved to an installable set of packages."

所以我用 Symfony 2.8.6 开发了这个博客。我注意到 Symfony3.1 版本可用并希望升级。因此,我修复了所有弃用调用。

我抓取了 Symfony3.1 的 composer.json 文件并尝试 运行

$ composer update

但是,更新失败,我得到以下输出:

Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - phpunit/phpunit 5.3.4 requires phpspec/prophecy ^1.3.1 -> satisfiable by phpspec/prophecy[v1.6.0, 1.4.0, v1.3.1, v1.4.1, v1.5.0].
    - phpunit/phpunit 5.3.0 requires phpspec/prophecy ^1.3.1 -> satisfiable by phpspec/prophecy[v1.6.0, 1.4.0, v1.3.1, v1.4.1, v1.5.0].
    - phpunit/phpunit 5.3.1 requires phpspec/prophecy ^1.3.1 -> satisfiable by phpspec/prophecy[v1.6.0, 1.4.0, v1.3.1, v1.4.1, v1.5.0].
    - phpunit/phpunit 5.3.2 requires phpspec/prophecy ^1.3.1 -> satisfiable by phpspec/prophecy[v1.6.0, 1.4.0, v1.3.1, v1.4.1, v1.5.0].
    - phpunit/phpunit 5.3.3 requires phpspec/prophecy ^1.3.1 -> satisfiable by phpspec/prophecy[v1.6.0, 1.4.0, v1.3.1, v1.4.1, v1.5.0].
    - phpunit/phpunit 5.3.4 requires phpspec/prophecy ^1.3.1 -> satisfiable by phpspec/prophecy[v1.6.0, 1.4.0, v1.3.1, v1.4.1, v1.5.0].
    - phpspec/prophecy v1.6.0 requires phpdocumentor/reflection-docblock ~2.0 -> satisfiable by phpdocumentor/reflection-docblock[2.0.4, 2.0.0, 2.0.1, 2.0.2, 2.0.3].
    - phpspec/prophecy 1.4.0 requires phpdocumentor/reflection-docblock ~2.0 -> satisfiable by phpdocumentor/reflection-docblock[2.0.4, 2.0.0, 2.0.1, 2.0.2, 2.0.3].
    - phpspec/prophecy v1.3.1 requires phpdocumentor/reflection-docblock ~2.0 -> satisfiable by phpdocumentor/reflection-docblock[2.0.4, 2.0.0, 2.0.1, 2.0.2, 2.0.3].
    - phpspec/prophecy v1.4.1 requires phpdocumentor/reflection-docblock ~2.0 -> satisfiable by phpdocumentor/reflection-docblock[2.0.4, 2.0.0, 2.0.1, 2.0.2, 2.0.3].
    - phpspec/prophecy v1.5.0 requires phpdocumentor/reflection-docblock ~2.0 -> satisfiable by phpdocumentor/reflection-docblock[2.0.4, 2.0.0, 2.0.1, 2.0.2, 2.0.3].
    - phpspec/prophecy v1.6.0 requires phpdocumentor/reflection-docblock ~2.0 -> satisfiable by phpdocumentor/reflection-docblock[2.0.4, 2.0.0, 2.0.1, 2.0.2, 2.0.3].
    - phpdocumentor/reflection-docblock 2.0.0 conflicts with symfony/symfony[v3.1.0].
    - phpdocumentor/reflection-docblock 2.0.1 conflicts with symfony/symfony[v3.1.0].
    - phpdocumentor/reflection-docblock 2.0.2 conflicts with symfony/symfony[v3.1.0].
    - phpdocumentor/reflection-docblock 2.0.3 conflicts with symfony/symfony[v3.1.0].
    - phpdocumentor/reflection-docblock 2.0.4 conflicts with symfony/symfony[v3.1.0].
    - symfony/symfony v3.1.0 conflicts with phpdocumentor/reflection-docblock[2.0.4].
    - Installation request for symfony/symfony 3.1.* -> satisfiable by symfony/symfony[v3.1.0].
    - Installation request for phpunit/phpunit 5.3.* -> satisfiable by phpunit/phpunit[5.3.0, 5.3.1, 5.3.2, 5.3.3, 5.3.4].

这是我的 composer.json:

{
    "name": "symfony/framework-standard-edition",
    "license": "MIT",
    "type": "project",
    "description": "The \"Symfony Standard Edition\" distribution",
    "autoload": {
        "psr-4": { "": "src/" },
        "classmap": [ "app/AppKernel.php", "app/AppCache.php" ]
    },
    "autoload-dev": {
        "psr-4": { "Tests\": "tests/" }
    },
    "require": {
        "php": ">=5.5.9",
        "symfony/symfony": "3.1.*",
        "doctrine/orm": "^2.5",
        "doctrine/doctrine-bundle": "^1.6",
        "doctrine/doctrine-cache-bundle": "^1.2",
        "symfony/swiftmailer-bundle": "^2.3",
        "symfony/monolog-bundle": "^2.8",
        "symfony/polyfill-apcu": "^1.0",
        "sensio/distribution-bundle": "^5.0",
        "sensio/framework-extra-bundle": "^3.0.2",
        "incenteev/composer-parameter-handler": "^2.0",
        "symfony/assetic-bundle": "^2.7",
        "knplabs/knp-time-bundle": "^1.6",
        "eko/feedbundle": "^1.2",
        "friendsofsymfony/user-bundle": "dev-master",
        "lexik/maintenance-bundle": "dev-master",
        "phpunit/phpunit": "5.3.*"
    },
    "require-dev": {
        "sensio/generator-bundle": "^3.0",
        "symfony/phpunit-bridge": "^3.0"
    },
    "scripts": {
        "post-install-cmd": [
            "Incenteev\ParameterHandler\ScriptHandler::buildParameters",
            "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap",
            "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache",
            "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installAssets",
            "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installRequirementsFile",
            "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::prepareDeploymentTarget"
        ],
        "post-update-cmd": [
            "Incenteev\ParameterHandler\ScriptHandler::buildParameters",
            "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap",
            "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache",
            "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installAssets",
            "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installRequirementsFile",
            "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::prepareDeploymentTarget"
        ]
    },
    "config": {
        "bin-dir": "bin",
        "platform": {
            "php": "5.6.16"
        }
    },
    "extra": {
        "symfony-app-dir": "app",
        "symfony-bin-dir": "bin",
        "symfony-var-dir": "var",
        "symfony-web-dir": "web",
        "symfony-tests-dir": "tests",
        "symfony-assets-install": "relative",
        "incenteev-parameters": {
            "file": "app/config/parameters.yml"
        },
        "branch-alias": {
            "dev-master": "3.1-dev"
        }
    }
}

我也尝试在 运行 宁 composer update 时添加 --with-dependencies 选项,但无济于事。

有谁知道哪个包有冲突吗?

这是由于a conflict between Symfony 3.1 and phpdocumentor/reflection-docblock: <3.0(PHPUnit要求的),在composer.json文件中声明:

"conflict": {
    "phpdocumentor/reflection-docblock": "<3.0"
},

来源:https://github.com/symfony/symfony/blob/b004243cb31059f9a97c0a1a045c2dbd1a77dee8/composer.json#L92

您有几种解决方案: