gpt4 book ai didi

Symfony2 - 环境 - 无法从公共(public)文件夹导入 routing.yml

转载 作者:行者123 更新时间:2023-12-04 02:01:43 27 4
gpt4 key购买 nike

我正在尝试创建一个文件夹结构,如 Different Directories per Environment 中所述:

- app
- config
- common
- config.yml
- routing.yml
- dev
- config.yml
- routing.yml

这对于所有文件(config.ymlparameters.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');
}

dev

中的 routing.yml
#app/config/dev/routing.yml
imports:
- { resource: ../common/routing.yml }

config.yml 在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"

dev

中的 config.yml
#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"

我在这里错过了什么?

最佳答案

我终于让它运行起来了。我已经在我的开发配置中设置了新的路由文件:

#app/config/dev/config.yml
framework:
# update routing
router:
resource: "%kernel.root_dir%/config/dev/routing.yml"

并且我通过不使用 imports: - { resource: ../common/routing.yml }dev 路由 中导入了 common 路由而是这个:

#app/config/dev/routing.yml
_common:
resource: ../common/routing.yml

像魅力一样工作。似乎 import routing.yml 中不允许使用指令.

关于Symfony2 - 环境 - 无法从公共(public)文件夹导入 routing.yml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30571835/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com