简体   繁体   中英

Symfony2 install bundles with composer

I'm creating a site using the Symfony 2 and I have big problems with installing KnpMenuBundle . I read a lot about such problems. And I tried a lot of variants how to fix this. But nothing helps.

This is my composer.json file:

{
    "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"
        }
    }
}

and here is what I got in console

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.

The package knplabs/knp-menu-bundle has a requirement to knplabs/knp-menu with the version 2.0.* . But this dependency has no tagged 2.0 release. The simplest way to accomplish this, is to use the dev version of the dependency. Simply add this to your reqirements:

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

Then you should get following output (commit-sha may differ):

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

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

Last step is to activate the bundle in the app/AppKernel.php :

public function registerBundles()
{
    $bundles = array(
        // ...
        new Knp\Bundle\MenuBundle\KnpMenuBundle(),
    );
    // ...
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM