Accessing, Getting and Setting Config, Parameters or Settings in Symfony2
Most web applications will require some specific constants or settings that can be used by any bundle or service. In Symfony2 this is very simple. You can add any parameters you need to the /app/config/config.yml file like this:
parameters:
email_address: "john.smith@anybody.com"
To then access that variable in a bundle controller or service we can then use the code:
$email_address = $this->container->getParameter('email_address');
If we don’t want to use the config.yml file and want to set your own parameter through a bundle controller or service you can set a parameter using:
$this->container->setParameter('email_address', 'someone.else@anybody.com');




