How to access a Symfony 2 bundle configuration from outside the bundle? How to access a Symfony 2 bundle configuration from outside the bundle? symfony symfony

How to access a Symfony 2 bundle configuration from outside the bundle?


The whole config is exposed in the parameter paggy_boleto.config as an nested array. To access it, in controller:

$config = $this->container->getParameter('paggy_boleto.config');

var_dump the config to see, how you access the entries in it.

If you need access others bundle config you have to take a look in the bundles Extension class, how they expose the config into the di container. Some bundle like yours exposes the whole config, some other bundles don't (they expose only specific parameters).

In the PaggyBaletoBundle this is the relevant line:

$container->setParameter('paggy_boleto.config', $config);


It depends how you implemented bundle's configuration builder - it prepends its parameters with a certain prefix.

According to your case it is paggy_boleto.config


You should use parameters.yml for that purpose. and then you can easily get the things in your controller like this

$parameters = $this->container->getParameter('devices');