所以我想安装Sonata Admin Bundle和Sonata User Bundle。
根据他们的页面,AdminBundle requires KNPMenuBundle in version 2.*
所以我的composer.json
看起来像这样:
"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']);
在版本1.3中Sonata
需要KnpMenuBundle
的堆栈中有很多信息,但正如我所写,在dev-master
bramch中,Sonata需要在版本2中使用KnpMenuBndle。*
答案 0 :(得分:2)
最后,我想出来了!
如果您想使用Sonata AdminPanel&amp; Sonada 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": "~2.2@dev",
"sonata-project/admin-bundle": "~2.3@dev",
"sonata-project/doctrine-orm-admin-bundle": "~2.3@dev",
"stof/doctrine-extensions-bundle": "~1.1@dev",
"sonata-project/user-bundle": "~2.3@dev"
},
您可以使用1.3版本的FOSUserBundle,但它仅支持2.1版本的SF2。 FOS 1.3。*支持2.6版本的SF2。
"friendsofsymfony/user-bundle": "1.3.*@dev"