Symfony 2 loading custom configuration file Symfony 2 loading custom configuration file symfony symfony

Symfony 2 loading custom configuration file


Well, I have not tried it but you should be able to use the Yaml extension to load in the canonisers.yml file directly and add it to configs. Not recommended (bypasses the application caching stuff) but it might work:

use Symfony\Component\Yaml\Yaml;class MailbrokerMailDetailsExtension extends Extension{    public function load(array $configs, ContainerBuilder $container)    {        $file = __DIR__.'/../Resources/config/canonisers.yml';        $configs = array_merge($configs,Yaml::parse(file_get_contents($file));        $configuration = new Configuration();        $config = $this->processConfiguration($configuration, $configs);        ....

Completely untested. You might need to add to app/config/config.yml

mailbroker_mail_details: ~

Just to get past the error message. Not sure.

Let me know if it works.


Ok, so @Iltar from #symfony irc channel pointed me to cookbook: http://symfony.com/doc/current/cookbook/bundles/prepend_extension.html

Long story short, PrependExtensionInterface with prepend method.

It was added since I last read through symfony book and cookbook, and it wasn't exactly googlable in this case, so I'll just leave the link here for other people.