InvalidConfigurationException安装Symfony2 CMF

时间:2013-11-08 17:54:56

标签: php symfony symfony-sonata symfony-cmf

刚进入Symfony2,我想使用CMF捆绑包。

我在这里关注这本食谱: http://symfony.com/doc/current/cmf/cookbook/editions/cmf_core.html

运行时

composer.phar update

我收到此错误:

    [Symfony\Component\Config\Definition\Exception\InvalidConfigurationException]                                                                                
  When the dynamic router is enabled, you need to either enable one of the persistence layers or set the cmf_routing.dynamic.route_provider_service_id option  

route_provider_service_id的正确设置是什么?我找不到任何关于此的文档。

config.yml

# CMF config
cmf_routing:
chain:
    routers_by_id:
        cmf_routing.dynamic_router: 200
        router.default: 100
dynamic:
    enabled: true
    route_provider_service_id: ~
sonata_block:
    default_contexts: [cms]

这是我的composer.json文件:

{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
    "psr-0": { "": "src/" }
},
"minimum-stability": "dev",
"require": {
    "php": ">=5.3.3",
    "symfony/symfony": "2.3.*",
    "doctrine/orm": ">=2.2.3,<2.4-dev",
    "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",
    "jackalope/jackalope-doctrine-dbal": "dev-master",
    "doctrine/phpcr-bundle": "1.0.*",
    "doctrine/phpcr-odm": "1.0.*",
    "symfony-cmf/symfony-cmf": "1.0.*"
},
"scripts": {
    "post-install-cmd": [
        "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
        "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": [
        "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
        "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"
},
"extra": {
    "symfony-app-dir": "app",
    "symfony-web-dir": "web",
    "incenteev-parameters": {
        "file": "app/config/parameters.yml"
    },
    "branch-alias": {
        "dev-master": "2.3-dev"
    }
}

}

如果有人能够对这些cmf_routing设置有所启发,那么从作曲家那里获得一个干净的更新会很棒。

我发现这个新的Sym2方法令人沮丧的一件事是它似乎是你需要的每个包,带有另一个必需的包,编译你的错误和混乱的可能性。

更新

我在这里查看了动态配置: http://symfony.com/doc/master/cmf/reference/configuration/routing.html#dynamic

它说的是关于route_provider_service_id:

route_provider_service_id

type:string

如果未启用任何持久层,则必须提供路由提供程序服务才能获取路由。这是通过使用route_provider_service_id设置完成的。

我知道如果我没有设置持久性,我应该添加此设置。我知道设置应该是一个字符串。但是我不知道service_id到底是什么,所以我不知道设置是什么。也许我还不清楚我在使用动态路由器做什么。

我能够通过启用persistence.phpcr并给出manager_name:null

来解决这个问题

删除了错误,但可能是定义manager_name是让CMF落地的重要一步。

1 个答案:

答案 0 :(得分:1)

您需要配置路由提供程序。否则路由器将不知道如何加载路由。动态路由器的想法是你可以从数据库加载路由,所以你需要告诉它如何加载它们。您可以启用persistence.phpcr或persistence.orm,也可以提供自己的服务。

这里介绍了cmf路由 http://symfony.com/doc/master/cmf/book/routing.html

此处有更多细节http://symfony.com/doc/master/cmf/bundles/routing/dynamic.html(我刚刚向路由提供商澄清了一点,因为我意识到它不是很明确)。

路由的配置参考如下: http://symfony.com/doc/master/cmf/reference/configuration/routing.html#dynamic