composer 无法在 symfony 3.4 中安装 knp 菜单包

composer cannot install knp menu bundle in symfony 3.4

我尝试在 Symfony 3.4 中安装 knp-menu-bundle,但出现以下错误:

$作曲家需要knplabs/knp-menu-bundle开发大师

[InvalidArgumentException]

包 knplabs/knp-menu-bundle 版本 dev-master 的 PHP 要求与您的 PHP 版本 (5.5.9)

不兼容

奇怪,因为我的 PHP 版本是 7.1 而不是 5.5.9。

正在更新我的 post 以显示我的 composer.json。

{
    "name": "symfony/framework-standard-edition",
    "license": "MIT",
    "type": "project",
    "description": "The \"Symfony Standard Edition\" distribution",
    "autoload": {
        "psr-4": {
            "AppBundle\": "src/AppBundle",
            "CarBundle\": "src/CarBundle"
        },
        "classmap": [ "app/AppKernel.php", "app/AppCache.php" ]
    },
    "autoload-dev": {
        "psr-4": { "Tests\": "tests/" },
        "files": [ "vendor/symfony/symfony/src/Symfony/Component/VarDumper/Resources/functions/dump.php" ]
    },
    "require": {
        "php": ">=5.5.9",
        "doctrine/doctrine-bundle": "^1.6",
        "doctrine/orm": "^2.5",
        "incenteev/composer-parameter-handler": "^2.0",
        "sensio/distribution-bundle": "^5.0.19",
        "sensio/framework-extra-bundle": "^5.0.0",
        "symfony/monolog-bundle": "^3.1.0",
        "symfony/polyfill-apcu": "^1.0",
        "symfony/swiftmailer-bundle": "^2.6.4",
        "symfony/symfony": "3.4.*",
        "twig/twig": "^1.0||^2.0"
    },
    "require-dev": {
        "sensio/generator-bundle": "^3.0",
        "symfony/phpunit-bridge": "^3.0"
    },
    "scripts": {
        "symfony-scripts": [
            "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-install-cmd": [
            "@symfony-scripts"
        ],
        "post-update-cmd": [
            "@symfony-scripts"
        ]
    },
    "config": {
        "platform": {
            "php": "5.5.9"
        },
        "sort-packages": true
    },
    "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.4-dev"
        }
    }
}

尝试在 composer require knplabs/knp-menu-bundle "^2.0" 下面不使用 dev-master 或更改

 "require": {
        "php": ">=7.0",
        ...............

问题是 knplabs/knp-menu-bundle 需要以下内容:

"php": "^5.6 || ^7",

你可以看到 here。但是您的 composer.json 有:

"php": ">=5.5.9",

所以你至少需要 5.6 才能使 knp-menu-bundle 依赖项满意。您仍然需要检查是否也适用于所有其他依赖项。