they must be available in different packages as well as in templates
They are. While you can access the container, you can access the parameters. From the documents you are associated with: $container->getParameter('acme_hello.email.from');
I think there is an error in your parameters.ini
example. 'flickr' and 'app' must not be enclosed in brackets. In addition, the first element of parameters.ini should be [parameters]
.
Personally, I like to use the app.yml
file because I use it in Symfony 1.x projects (and because I see no reason to use the .ini file). You can create app/config/app.yml
and import it into your app/config/config.yml
as follows:
imports: - { resource: app.yml }
Your app.yml will look like this:
parameters: flickr: callbackUrl: http://example.com/approve requestTokenUrl: http://www.flickr.com/services/oauth/request_token consumerKey: 123a1237a29b123a5541232e0279123 app: default_layout: 2
And so you get access to the data: $container->getParameter('flickr.callbackUrl');
The third option is to define your parameters directly in app/config/config.yml
. The code will be exactly the same as my example for app/config/app.yml
. I do not recommend doing this because app/config/config.yml
can be populated with package configuration parameters, and I think it is cleaner to have your own application settings in a separate file. But, of course, it all depends on you.
source share