我目前正在尝试在空的Symfony2.4项目上安装sonata-admin 软件包。 我下载了以下软件包:
php composer.phar require sonata-project/admin-bundle
php composer.phar require sonata-project/doctrine-orm-admin-bundle
我在 appkernel.php:
中注册了这些捆绑包new Sonata\CoreBundle\SonataCoreBundle(),
new Sonata\BlockBundle\SonataBlockBundle(),
new Sonata\jQueryBundle\SonatajQueryBundle(),
new Knplabs\KnpMenuBundle\Knp\Bundle\MenuBundle\KnpMenuBundle(),
new Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle(),
new Sonata\AdminBundle\SonataAdminBundle(),
我在 config.yml 文件中添加了这些行,如文档中所述:
sonata_block:
default_contexts: [cms]
blocks:
# Enable the SonataAdminBundle block
sonata.admin.block.admin_list:
contexts: [admin]
但每次我试图跑:
php app/console assets:install web
或
php composer.phar update
我一直收到同样的错误:
class 'Sonata\CoreBundle\SonataCoreBundle" not found in AppKernel.php
实际上这个类似乎是在我的供应商文件夹中的“Sonata-project \ CoreBundle”fodler,但它不应该是一个问题,因为我在Sonata Admin Bundle工作的旧项目中有完全相同的东西精细。
有人知道我在这里做错了吗?
答案 0 :(得分:2)
要使用sonata admin bundle,您需要在composer.json中使用以下包:
"knplabs/knp-snappy-bundle": "dev-master",
"knplabs/knp-menu-bundle": "~1.1",
"sonata-project/core-bundle": "2.2.4",
"sonata-project/media-bundle": "2.2.7",
"sonata-project/admin-bundle": "2.2.9",
"sonata-project/notification-bundle": "2.2.4",
"sonata-project/jquery-bundle": "1.8.x-dev",
"sonata-project/cache-bundle": "2.1.5",
"sonata-project/easy-extends-bundle": "2.1.4",
"sonata-project/exporter": "1.3.1",
"sonata-project/doctrine-extensions": "1.0.1",
"knplabs/gaufrette": "dev-master",
"sonata-project/block-bundle": "2.2.9",
"sonata-project/doctrine-orm-admin-bundle": "2.2.6",
我使用静态版本,但如果你想要最新版本,请随意用“dev-master”替换每个软件包版本。
和我在appKernel.php中声明的奏鸣曲:
new Knp\Bundle\SnappyBundle\KnpSnappyBundle(),
new Knp\Bundle\MenuBundle\KnpMenuBundle(),
new Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle(),
new Sonata\CoreBundle\SonataCoreBundle(),
new Sonata\BlockBundle\SonataBlockBundle(),
new Sonata\CacheBundle\SonataCacheBundle(),
new Sonata\jQueryBundle\SonatajQueryBundle(),
new Sonata\AdminBundle\SonataAdminBundle(),
希望它会有所帮助