2

Итак, я хочу установить Sonata Admin Bundle и Sonata User Bundle. Согласно их странице, AdminBundle requires KNPMenuBundle in version 2.* Так мой composer.json выглядит следующим образом:Symfony2 - Sonata & KnpMenu - setCurrentUri

"require": { 
    "php": ">=5.3.3", 
    "symfony/symfony": "2.6.*", 
    "doctrine/orm": "~2.2,>=2.2.3,<2.5", 
    "doctrine/dbal": "<2.5", 
    "doctrine/doctrine-bundle": "~1.2", 
    "twig/extensions": "~1.0", 
    "twbs/bootstrap": "~3", 
    "components/jquery": "dev-master", 
    "symfony/assetic-bundle": "~2.3", 
    "symfony/swiftmailer-bundle": "~2.3", 
    "symfony/monolog-bundle": "~2.4", 
    "sensio/distribution-bundle": "~3.0,>=3.0.12", 
    "sensio/framework-extra-bundle": "~3.0,>=3.0.2", 
    "incenteev/composer-parameter-handler": "~2.0", 
    "friendsofsymfony/user-bundle": "1.3.*", 
    "sonata-project/doctrine-orm-admin-bundle": "2.4.*@dev", 
    "sonata-project/admin-bundle": "dev-master", 
    "sonata-project/easy-extends-bundle": "^2.1", 
    "sonata-project/user-bundle": "^2.2" 
}, 

И AppKernel.php как этот

$bundles = [ 
    new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), 
    new Symfony\Bundle\SecurityBundle\SecurityBundle(), 
    new Symfony\Bundle\TwigBundle\TwigBundle(), 
    new Symfony\Bundle\MonologBundle\MonologBundle(), 
    new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(), 
    new Symfony\Bundle\AsseticBundle\AsseticBundle(), 
    new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(), 
    new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(), 
    new My\ProductBundle\MyPdBundle(), 
    new FOS\UserBundle\FOSUserBundle(), 
    new Sonata\UserBundle\SonataUserBundle('FOSUserBundle'), 
    new Sonata\EasyExtendsBundle\SonataEasyExtendsBundle(), 
    new Sonata\CoreBundle\SonataCoreBundle(), 
    new Sonata\BlockBundle\SonataBlockBundle(), 
    new Knp\Bundle\MenuBundle\KnpMenuBundle(), 
    new Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle(), 

    new Application\Sonata\UserBundle\ApplicationSonataUserBundle(), 
    new Sonata\AdminBundle\SonataAdminBundle(), 
    ]; 

Но когда я пытаюсь посетить mypage.local/app_dev.php/profile я получил эту ошибку:

Attempted to call method "setCurrentUri" on class "Knp\Menu\MenuItem". 
Did you mean to call "setCurrent"? 
500 Internal Server Error - UndefinedMethodException 

in vendor/sonata-project/user-bundle/Block/ProfileMenuBlockService.php at line 91 
$menu->setCurrentUri($settings['current_uri']); 

В стеке много информации, что Sonata требует KnpMenuBundle в версии 1.3, но, как я писал, In dev-master bramch Sonata требует KnpMenuBndle в версии 2. *

ответ

2

Наконец-то я понял!

Если вы хотите использовать Sonata админпанель & Сонаде Userpanel (с FOSUserBundle) здесь работает конфигурация:

"require": { 
    "php": ">=5.3.3", 
    "symfony/symfony": "2.6.*", 
    "doctrine/orm": "~2.2,>=2.2.3,<2.5", 
    "doctrine/dbal": "<2.5", 
    "doctrine/doctrine-bundle": "~1.2", 
    "twig/extensions": "~1.0", 
    "symfony/assetic-bundle": "~2.3", 
    "symfony/swiftmailer-bundle": "~2.3", 
    "symfony/monolog-bundle": "~2.4", 
    "sensio/distribution-bundle": "~3.0,>=3.0.12", 
    "sensio/framework-extra-bundle": "~3.0,>=3.0.2", 
    "incenteev/composer-parameter-handler": "~2.0", 
    "friendsofsymfony/user-bundle": "1.3.*@dev", 
    "sonata-project/block-bundle": "2.3.*@dev", 
    "sonata-project/easy-extends-bundle": "^2.1", 
    "sonata-project/datagrid-bundle": "[email protected]", 
    "sonata-project/admin-bundle": "[email protected]", 
    "sonata-project/doctrine-orm-admin-bundle": "[email protected]", 
    "stof/doctrine-extensions-bundle": "[email protected]", 
    "sonata-project/user-bundle": "[email protected]" 
}, 

Вы можете использовать 1.3 версии FOSUserBundle, но он поддерживает только SF2 в версии 2.1. FOS 1.3. * Поддерживает SF2 в версии 2.6.

"friendsofsymfony/user-bundle": "1.3.*@dev"