Rob*_*_UK 5 configuration yaml symfony
我希望创建自己的yml文件来存储我可以在我的项目中重复使用的一些全局设置和变量.我在这里搜索并找到了另一个答案,但它对我不起作用
我想添加report_settings.yml文件,以便它自动加载到我的项目中.
这是我迄今为止的基础
#app/config/config.yml
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: report_settings.yml }
.. rest of config file --
Run Code Online (Sandbox Code Playgroud)
和我试图包含的文件看起来像这样
#report_settings.yml
something:
something1: "test"
Run Code Online (Sandbox Code Playgroud)
它返回以下错误
FileLoaderLoadException: Cannot import resource "/var/www/pcPortal/app/config/report_settings.yml" from "/var/www/pcPortal/app/config/config.yml".
Run Code Online (Sandbox Code Playgroud)
和
InvalidArgumentException: There is no extension able to load the configuration for "something" (in /var/www/pcPortal/app/config/report_settings.yml). Looked for namespace "something", found "framework", "security", "twig", "monolog", "swiftmailer", "assetic", "doctrine", "sensio_framework_extra", "jms_aop", "jms_di_extra", "jms_security_extra", "sj_query", "web_profiler", "sensio_distribution"
Run Code Online (Sandbox Code Playgroud)
从阅读错误消息看起来我错过了什么?我需要添加某种扩展吗?
最简单的方法是将配置放入参数部分,如:
#report_settings.yml
parameters:
something.something1: "test"
Run Code Online (Sandbox Code Playgroud)
您也可以使用自己的扩展程序处理配置,请参阅http://symfony.com/doc/master/book/service_container.html#importing-configuration-via-container-extensions