当我尝试访问/ cms / simple / contact(或来自phpcr_nodes表的任何其他路径)时,我收到以下错误:
Notice: Undefined offset: 0 in /home/xx/xx/xx/public_html/vendor/symfony/symfony/src/Symfony/Component/Routing/RouteCompiler.php line 169
首先,我不是将Symfony CMF作为一个独立的,而只是作为一个更大的项目的一小部分。我们需要最终用户对部分页面进行WYSIWYG页面编辑。
一些配置:
composer.json
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.3.*",
"doctrine/orm": "2.3.*",
"doctrine/doctrine-bundle": "1.2.*",
"twig/extensions": "1.0.*",
"symfony/assetic-bundle": "2.3.*",
"symfony/swiftmailer-bundle": "2.3.*",
"symfony/monolog-bundle": "2.3.*",
"sensio/distribution-bundle": "2.3.*",
"sensio/framework-extra-bundle": "2.3.*",
"sensio/generator-bundle": "2.3.*",
"incenteev/composer-parameter-handler": "~2.0",
"ircmaxell/password-compat": "1.0.*",
"sonata-project/seo-bundle": "1.1.*",
"leaseweb/memcache-bundle": "*",
"facebook/php-sdk" : "3.2.*",
"phpunit/dbunit": ">=1.2",
"symfony-cmf/symfony-cmf": "1.0.*",
"symfony-cmf/simple-cms-bundle": "1.0.*",
"symfony-cmf/create-bundle": "1.0.*",
"jackalope/jackalope-doctrine-dbal": "1.0.*",
"doctrine/data-fixtures": "1.0.*",
"lunetics/locale-bundle": "2.2.*",
"liip/doctrine-cache-bundle": "1.0.*",
"liip/imagine-bundle": "~0.12",
"wjzijderveld/check-bundles": "1.0.*@dev",
"doctrine/phpcr-bundle": "1.0.*",
"doctrine/phpcr-odm": "1.0.*",
"sonata-project/doctrine-phpcr-admin-bundle": "1.0.*"
},
App Kernel:
new Doctrine\Bundle\PHPCRBundle\DoctrinePHPCRBundle(),
new Liip\DoctrineCacheBundle\LiipDoctrineCacheBundle(),
new Knp\Bundle\MenuBundle\KnpMenuBundle(),
new Lunetics\LocaleBundle\LuneticsLocaleBundle(),
new FOS\RestBundle\FOSRestBundle(),
new JMS\SerializerBundle\JMSSerializerBundle($this),
new Liip\ImagineBundle\LiipImagineBundle(),
// enable cmf bundles
new Symfony\Cmf\Bundle\RoutingBundle\CmfRoutingBundle(),
new Symfony\Cmf\Bundle\CoreBundle\CmfCoreBundle(),
new Symfony\Cmf\Bundle\MenuBundle\CmfMenuBundle(),
new Symfony\Cmf\Bundle\ContentBundle\CmfContentBundle(),
new Symfony\Cmf\Bundle\SimpleCmsBundle\CmfSimpleCmsBundle(),
new Symfony\Cmf\Bundle\MediaBundle\CmfMediaBundle(),
new Symfony\Cmf\Bundle\CreateBundle\CmfCreateBundle(),
// support for the admin
new Symfony\Cmf\Bundle\TreeBrowserBundle\CmfTreeBrowserBundle(),
new Sonata\jQueryBundle\SonatajQueryBundle(),
new Sonata\BlockBundle\SonataBlockBundle(),
new Sonata\AdminBundle\SonataAdminBundle(),
new Sonata\DoctrinePHPCRAdminBundle\SonataDoctrinePHPCRAdminBundle(),
new FOS\JsRoutingBundle\FOSJsRoutingBundle(),
config.yml
doctrine_phpcr:
# configure the PHPCR session
session:
backend: %phpcr_backend%
workspace: %phpcr_workspace%
username: %phpcr_user%
password: %phpcr_pass%
# enable the ODM layer
odm:
auto_mapping: true
auto_generate_proxy_classes: %kernel.debug%
locales:
en:
- rs
liip_doctrine_cache:
namespaces:
meta:
type: file_system
nodes:
type: file_system
cmf_core:
persistence:
phpcr:
enabled: true
basepath: /cms
publish_workflow:
enabled: false
multilang:
locales: %locales%
cmf_create:
editor_base_path: /bundles/cmfcreate/vendor/ckeditor/
cmf_simple_cms:
routing:
templates_by_class:
Symfony\Cmf\Bundle\SimpleCmsBundle\Doctrine\Phpcr\Page: CmfSimpleCmsBundle:Page:index.html.twig
controllers_by_class:
Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\RedirectRoute: cmf_routing.redirect_controller:redirectAction
knp_menu:
twig: true
lunetics_locale:
strict_mode: true
guessing_order:
- cookie
- router
- browser
allowed_locales: %locales%
sonata_block:
default_contexts: [cms]
blocks:
sonata.admin.block.admin_list:
contexts: [admin]
sonata_admin_doctrine_phpcr.tree_block:
settings:
id: '/cms'
contexts: [admin]
cmf_routing:
chain:
routers_by_id:
cmf_routing.dynamic_router: 200
router.default: 100
dynamic:
enabled: true
sonata_admin:
templates:
# default global templates
ajax: SonataAdminBundle::ajax_layout.html.twig
dashboard:
blocks:
# display a dashboard block
- { position: right, type: sonata.admin.block.admin_list }
- { position: left, type: sonata_admin_doctrine_phpcr.tree_block }
sonata_doctrine_phpcr_admin:
document_tree:
Doctrine\ODM\PHPCR\Document\Generic:
valid_children:
- all
# if you are using the SimpleCmsBundle, enable the Page as well
Symfony\Cmf\Bundle\SimpleCmsBundle\Doctrine\Phpcr\Page:
valid_children:
- all
Symfony\Cmf\Bundle\ContentBundle\Doctrine\Phpcr\StaticContent:
valid_children:
- all
Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\Route:
valid_children:
- Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\Route
- Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\RedirectRoute
Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\RedirectRoute:
valid_children: []
Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr\MenuNode:
valid_children:
- Symfony\Cmf\Bundle\MenuBundle\Doctrine\Phpcr\MenuNode
的routing.yml
cmf_create_rest:
resource: "@CmfCreateBundle/Resources/config/routing/rest.xml"
cmf_create_image:
resource: "@CmfCreateBundle/Resources/config/routing/image.xml"
admin:
resource: '@SonataAdminBundle/Resources/config/routing/sonata_admin.xml'
prefix: /admin
sonata_admin:
resource: .
type: sonata_admin
prefix: /admin
fos_js_routing:
resource: "@FOSJsRoutingBundle/Resources/config/routing/routing.xml"
cmf_tree:
resource: .
type: 'cmf_tree'
我也做了
$ php composer.phar update
$ php app/console doctrine:phpcr:init:dbal
$ php app/console doctrine:phpcr:repository:init
$ php app/console doctrine:phpcr:fixtures:load --append
(附加,因为我当然不会删除现有数据)
我检查了数据库,phpcr_nodes包含适当的数据。在调用RouteCompiler之前我也做了var_dumps几步,并且确实正确地加载了来自DB的数据。
我错过了什么?