1

我正在使用 Symfony 2 创建一个站点,但在安装KnpMenuBundle. 我读了很多关于这些问题的文章。我尝试了很多变体来解决这个问题。但没有任何帮助。

这是我的composer.json文件:

{
    "name": "symfony/framework-standard-edition",
    "description": "The \"Symfony Standard Edition\" distribution",
    "autoload": {
        "psr-0": { "": "src/" }
    },
    "require": {
        "php": ">=5.3.3",
        "symfony/symfony": "2.2.*",
        "doctrine/orm": "~2.2,>=2.2.3",
        "doctrine/doctrine-bundle": "1.2.*",
        "twig/extensions": "1.0.*",
        "symfony/assetic-bundle": "2.1.*",
        "symfony/swiftmailer-bundle": "2.2.*",
        "symfony/monolog-bundle": "2.2.*",
        "sensio/distribution-bundle": "2.2.*",
        "sensio/framework-extra-bundle": "2.2.*",
        "sensio/generator-bundle": "2.2.*",
        "jms/security-extra-bundle": "1.4.*",
        "jms/di-extra-bundle": "1.3.*",
        "doctrine/doctrine-fixtures-bundle": "dev-master",
        "doctrine/data-fixtures" : "dev-master",
        "knplabs/knp-paginator-bundle": "dev-master",
        "apy/datagrid-bundle": "2.2.*@dev",
        "friendsofsymfony/user-bundle": "*",
        "jms/security-extra-bundle": "1.4.x-dev",
        "knplabs/knp-menu-bundle":"dev-master"
    },
    "scripts": {
        "post-install-cmd": [
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
        ],
        "post-update-cmd": [
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
        ]
    },
    "config": {
        "bin-dir": "bin"
    },
    "minimum-stability": "dev",
    "extra": {
        "symfony-app-dir": "app",
        "symfony-web-dir": "web",
        "branch-alias": {
            "dev-master": "2.2-dev"
        }
    }
}

这是我在控制台中得到的

D:\Work\YouMustKnowIt_portal\Symfony>php composer.phar 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
    - Installation request for knplabs/knp-menu-bundle dev-master -> satisfiable
 by knplabs/knp-menu-bundle[dev-master].
    - knplabs/knp-menu-bundle dev-master requires knplabs/knp-menu 2.0.* -> no m
atching package found.

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your min
imum-stability setting
   see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> f
or more details.

Read <http://getcomposer.org/doc/articles/troubleshooting.md> for further common
 problems.
4

1 回答 1

1

该软件包对版本knplabs/knp-menu-bundle有要求。但是这个依赖没有标记 2.0 版本。完成此操作的最简单方法是使用依赖项的开发版本。只需将其添加到您的要求中:knplabs/knp-menu2.0.*

"knplabs/knp-menu": "2.0.*@dev"

然后你应该得到以下输出(commit-sha 可能不同):

- Installing knplabs/knp-menu (dev-master 5cf5ab4)
  Cloning 5cf5ab4948d8c573f260e2b612bfc9721da1c892

- Installing knplabs/knp-menu-bundle (dev-master a4d6b33)
  Cloning a4d6b338e47920880d1c972143ef39ffb564665f

最后一步是激活捆绑包app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Knp\Bundle\MenuBundle\KnpMenuBundle(),
    );
    // ...
}
于 2013-05-19T15:25:31.143 回答