Reputation: 2816
I'm trying to create a folder structure like described in Different Directories per Environment:
- app
- config
- common
- config.yml
- routing.yml
- dev
- config.yml
- routing.yml
This does work pretty well for all files (config.yml, parameters.yml etc.) but nor for config.yml.
I get this error:
The routing file "[…]" contains unsupported keys for "imports": "0". Expected one of: "resource", "type", "prefix", "pattern", "path", "host", "schemes", "methods", "defaults", "requirements", "options", "condition".
What I've done so far:
appKernel.php
public function registerContainerConfiguration(LoaderInterface $loader) {
$loader->load($this->getRootDir().'/config/'.$this->getEnvironment().'/config.yml');
}
routing.yml in dev
#app/config/dev/routing.yml
imports:
- { resource: ../common/routing.yml }
config.yml in common
#app/config/common/config.yml
imports:
- { resource: 'parameters.yml' }
- { resource: 'security.yml' }
- { resource: 'services.yml' }
framework:
router:
resource: "%kernel.root_dir%/config/common/routing.yml"
config.yml in dev
#app/config/dev/config.yml
imports:
- { resource: '../common/config.yml' }
- { resource: 'parameters.yml' }
- { resource: 'security.yml' }
- { resource: 'services.yml' }
framework:
router:
resource: "%kernel.root_dir%/config/dev/routing.yml"
What did I miss here?
Upvotes: 3
Views: 1115
Reputation: 2816
Finally I got it running. I have set the new routing file in my dev config:
#app/config/dev/config.yml
framework:
# update routing
router:
resource: "%kernel.root_dir%/config/dev/routing.yml"
And I imported the common routing in the dev routing by not using imports: - { resource: ../common/routing.yml }
but this instead:
#app/config/dev/routing.yml
_common:
resource: ../common/routing.yml
Works like a charm. It seems that the import
directive is not allowed in the routing.yml
.
Upvotes: 6