1

I looked after this, but I didn't found something useful. Is there a method like Symfony1.4 getConfig() in Symfony2.7 to get a config value from a Yaml file? Thanks in advance.

dMar
  • 55
  • 7

1 Answers1

3

Instead of define hard-coded configuration values, create a parameter :

# app/config/parameters.yml or app/config/config.yml
parameters:
    your_param: value # Define the parameter

Use it in your configuration :

# app/config/config.yml
my_package:
    my_parameter: "%your_param%"

Retrieve it from your controller or another context which can access the service container :

$this->container->getParameter('yourparam');

See DI and parameters and How do I read configuration settings from Symfony2 config.yml?

Community
  • 1
  • 1
chalasr
  • 12,971
  • 4
  • 40
  • 82
  • Thanks @chalasr, I used a mix of this solution and a little bit of hard coding to adapt this to my needs – dMar Mar 17 '16 at 07:04