使用 composer 安装 phpdocumentor/reflection

Installation of phpdocumentor/reflection with composer

我想在我的 SF2 项目中安装包 phpdocumentor/reflexion。 所以我 运行 以下命令 composer require "phpdocumentor/reflection" 但我有以下堆栈错误:

 Your requirements could not be resolved to an installable set of packages.

Problem 1

- Conclusion: don't install phpdocumentor/reflection 3.0.1
- Conclusion: remove phpdocumentor/reflection-docblock 3.1.1
- Installation request for phpdocumentor/reflection ^3.0 -> satisfiable by phpdocumentor/reflection[3.0.0, 3.0.1].                                                                                                │  Feature/T4136-18-identification-by-vin
- Conclusion: don't install phpdocumentor/reflection-docblock 3.1.1
- phpdocumentor/reflection 3.0.0 requires phpdocumentor/reflection-docblock ~2.0 -> satisfiable by phpdocumentor/reflection-docblock[2.0.0, 2.0.0a1, 2.0.0a2, 2.0.0a3, 2.0.1, 2.0.2, 2.0.3, 2.0.4].               │  master
- Can only install one of: phpdocumentor/reflection-docblock[2.0.0, 3.1.1].
- Can only install one of: phpdocumentor/reflection-docblock[2.0.0a1, 3.1.1].
- Can only install one of: phpdocumentor/reflection-docblock[2.0.0a2, 3.1.1].
- Can only install one of: phpdocumentor/reflection-docblock[2.0.0a3, 3.1.1].
- Can only install one of: phpdocumentor/reflection-docblock[2.0.1, 3.1.1].
- Can only install one of: phpdocumentor/reflection-docblock[2.0.2, 3.1.1].
- Can only install one of: phpdocumentor/reflection-docblock[2.0.3, 3.1.1].
- Can only install one of: phpdocumentor/reflection-docblock[2.0.4, 3.1.1].
- Installation request for phpdocumentor/reflection-docblock (locked at 3.1.1) -> satisfiable by phpdocumentor/reflection-docblock[3.1.1].

这是我的 composer.json :

{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
    "classmap": [ "app/AppKernel.php", "app/AppCache.php" ]
},
"require": {
    "php": ">=5.3.9",
    "symfony/symfony": "2.8.*",
    "symfony/serializer": "~3.1.5",
    "doctrine/orm": "^2.4.8",
    "doctrine/doctrine-bundle": "~1.4",
    "symfony/swiftmailer-bundle": "~2.3",
    "symfony/monolog-bundle": "~2.4",
    "sensio/distribution-bundle": "~5.0",
    "sensio/framework-extra-bundle": "^3.0.2",
    "incenteev/composer-parameter-handler": "~2.0"
},
"require-dev": {
    "sensio/generator-bundle": "~3.0",
    "symfony/phpunit-bridge": "~2.7",
    "phpunit/phpunit": "5.5.*"
},
"scripts": {
    "symfony-scripts": [
        "Incenteev\ParameterHandler\ScriptHandler::buildParameters",
        "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap",
        "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installRequirementsFile",
        "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::prepareDeploymentTarget"
    ],
    "post-install-cmd": [
        "@symfony-scripts"
    ],
    "post-update-cmd": [
        "@symfony-scripts"
    ]
},
"config": {
    "bin-dir": "bin",
    "platform": {
        "php": "5.6"
    }
},
"extra": {
    "symfony-app-dir": "app",
    "symfony-web-dir": "web",
    "symfony-assets-install": "relative",
    "incenteev-parameters": {
        "file": "app/config/parameters.yml"
    },
    "branch-alias": {
        "dev-master": "2.8-dev"
    }
}

}

我不知道问题出在哪里,但我认为作曲家尝试安装 phpdocumentor/reflection (3.0.1) 的最新稳定版本。这个包依赖于 phpdocumentor/reflection-docblock (~2.0) 但它应该是 3.1.1.

有什么解决这个问题的想法吗?

您的安装中似乎已经安装了 phpdocumentor/reflection-docblock 3.1.1,此软件包需要 phpdocumentor/reflection-docblock 3.0.*

删除 phpdocumentor/reflection-docblock 3.1.1 并再次尝试安装 phpdocumentor/reflexion

如果您想安装 phpdocumentor/reflection ~3.0 软件包,您 需要 phpdocumentor/reflection-docblock ~2.0。 问题是您已经安装了 phpdocumentor/reflection-docblock ~3.1 因为 phpspec/prophecy 1.6.1 需要 phpdocumentor/reflection-docblock (^2.0|^3.0.2).

好消息是 phpspec/prophecy 可以在 ~2.0 版本的 phpdocumentor/reflection-docblock 上正常工作,所以你可以先降级那个包。

composer require phpdocumentor/reflection-docblock:~2.0

然后你可以要求 phpdocumentor/reflection 没有冲突:

composer require phpdocumentor/reflection