Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

symfony2 how do you create your own custom yml file to share globally?

I am looking to create my own yml file to store some global settings and vars that I can re-use across my project. I have searched on here and found another answer however it does not work for me

Set own parameters in symfony2

I'm looking to add the report_settings.yml file so that its automatically loaded across my project.

this is what I have so far based

#app/config/config.yml
imports:
    - { resource: parameters.yml }
    - { resource: security.yml }
    - { resource: report_settings.yml }

 .. rest of config file --

and the file im trying to include looks like this

#report_settings.yml
something:
    something1: "test"

It returns the following error

FileLoaderLoadException: Cannot import resource "/var/www/pcPortal/app/config/report_settings.yml" from "/var/www/pcPortal/app/config/config.yml".

and

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"

From reading the error messages it looks like I have missed something out? Do I need to add some kind of extension?

like image 220
Robbo_UK Avatar asked Feb 13 '13 14:02

Robbo_UK


1 Answers

The simplest would be to put your config into the parameters section like:

#report_settings.yml
parameters:
    something.something1: "test"

You could also process the config with your own extension see http://symfony.com/doc/master/book/service_container.html#importing-configuration-via-container-extensions

like image 81
Michael Smith Avatar answered Nov 19 '22 15:11

Michael Smith