Symfony2 - 环境 - 无法从公共文件夹导入 routing.yml
Symfony2 - Environments - Can't import routing.yml from common folder
我正在尝试创建一个文件夹结构,如 Different Directories per Environment 中所述:
- app
- config
- common
- config.yml
- routing.yml
- dev
- config.yml
- routing.yml
这对所有文件(config.yml、parameters.yml 等)都非常有效,但也不config.yml.
我收到这个错误:
The routing file "[…]" contains unsupported keys for "imports": "0". Expected one of: "resource", "type", "prefix", "pattern", "path", "host", "schemes", "methods", "defaults", "requirements", "options", "condition".
到目前为止我做了什么:
appKernel.php
public function registerContainerConfiguration(LoaderInterface $loader) {
$loader->load($this->getRootDir().'/config/'.$this->getEnvironment().'/config.yml');
}
routing.yml 在 dev
#app/config/dev/routing.yml
imports:
- { resource: ../common/routing.yml }
config.yml 在普通
#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 在 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"
我错过了什么?
终于明白了运行。我已经在 dev config:
中设置了新的路由文件
#app/config/dev/config.yml
framework:
# update routing
router:
resource: "%kernel.root_dir%/config/dev/routing.yml"
并且我在 dev 路由 中导入了 公共路由 ,而不是使用 imports: - { resource: ../common/routing.yml }
,而是这样:
#app/config/dev/routing.yml
_common:
resource: ../common/routing.yml
很有魅力。似乎 import
指令在 routing.yml
.
中是不允许的
我正在尝试创建一个文件夹结构,如 Different Directories per Environment 中所述:
- app
- config
- common
- config.yml
- routing.yml
- dev
- config.yml
- routing.yml
这对所有文件(config.yml、parameters.yml 等)都非常有效,但也不config.yml.
我收到这个错误:
The routing file "[…]" contains unsupported keys for "imports": "0". Expected one of: "resource", "type", "prefix", "pattern", "path", "host", "schemes", "methods", "defaults", "requirements", "options", "condition".
到目前为止我做了什么:
appKernel.php
public function registerContainerConfiguration(LoaderInterface $loader) {
$loader->load($this->getRootDir().'/config/'.$this->getEnvironment().'/config.yml');
}
routing.yml 在 dev
#app/config/dev/routing.yml
imports:
- { resource: ../common/routing.yml }
config.yml 在普通
#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 在 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"
我错过了什么?
终于明白了运行。我已经在 dev config:
中设置了新的路由文件#app/config/dev/config.yml
framework:
# update routing
router:
resource: "%kernel.root_dir%/config/dev/routing.yml"
并且我在 dev 路由 中导入了 公共路由 ,而不是使用 imports: - { resource: ../common/routing.yml }
,而是这样:
#app/config/dev/routing.yml
_common:
resource: ../common/routing.yml
很有魅力。似乎 import
指令在 routing.yml
.