Obtenga los valores de configuración general de Symfony2 (¡no los parámetros!) En el controlador

How can I get values from config.yml or security.yml in the controller in Symfony2? I am not talking about the ones I define under "parameters" key (which one can easily get by $this->container->getParameter()), but those stored in upper levels.

For example, how can I get the security.firewalls.my_firewall.remember_me.key ¿valor?

preguntado el 31 de enero de 12 a las 08:01

There is nothing wrong with the approach if you need custom parameters, but I need the values which I specify for the framework anyway - like the remember_me.key. What's the point in duplicating this value in the config? -

You're right, I should do it this way. Thanks for your input, post it as an answer and I will accept it (+rep) ;) -

1 Respuestas

What's wrong with defining a value as a parameter and assigning it to a value in config.yml or security.yml? You can easily get it from a controller then.

For example, add a parameter to the parameters.ini archivo:

remember_me_key = some_key_here

And then use it in the security.yml archivo:

security.firewalls.my_firewall.remember_me.key: %remember_me_key%

And access it from a controller the way you already do.

Respondido 02 Feb 12, 00:02

how do he access it from a controller "the way you already do"? - Rubinum

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.