Search code examples
phpsymfonysymfony-sonatasymfony-cmf

InvalidConfigurationException installing Symfony2 CMF


Just getting into Symfony2 and I wanted to use the CMF bundle.

I am following the cookbook here: http://symfony.com/doc/current/cmf/cookbook/editions/cmf_core.html

When running

composer.phar update

I am getting this error:

    [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  

What is the proper setting for route_provider_service_id? I cannot find any docs on this.

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]

Here is my composer.json file:

{
"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"
    }
}

}

If anyone could just shine some light on these cmf_routing settings to get a clean update from composer would be great.

One thing that I find frustrating with this new Sym2 method is it seems every bundle you need, comes with another required bundle, compiling your probabilities for errors and confusion.

UPDATE

I have looked at the Dynamic configuration here: http://symfony.com/doc/master/cmf/reference/configuration/routing.html#dynamic

It says this about route_provider_service_id:

route_provider_service_id

type: string

When none of the persistence layers is enabled, a route provider service must be provided in order to get the routes. This is done by using the route_provider_service_id setting.

I understand if i do not set persistence, I should add this setting. I know the setting should be a string. But I don't know what the service_id actually is, so I don't know what the setting could be. Perhaps I am still unclear on what I am doing with the dynamic router.

I was able to fix this by enabling persistence.phpcr and giving the manager_name: null

Removed the error, but it could be that defining the manager_name is an important step in getting the CMF off the ground.


Solution

  • You need to configure the route provider. Otherwise the router won't know how to load routes. The idea of the dynamic router is that you can load routes from the database, so you need to tell it how to load them. you can either enable persistence.phpcr or persistence.orm, or provide your own service.

    There is an introduction to the cmf routing here http://symfony.com/doc/master/cmf/book/routing.html

    And more details here http://symfony.com/doc/master/cmf/bundles/routing/dynamic.html (i just clarified the thing with the route provider a bit more, as i realized it was not very explicit).

    The configuration reference for routing is here: http://symfony.com/doc/master/cmf/reference/configuration/routing.html#dynamic