Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where do I store general config parameters in Silex?

I have some general parameters I would like to share all along my application like path information ("baseurl"). Where would you ideally store this information in Silex?

like image 972
herrjeh42 Avatar asked Nov 05 '12 12:11

herrjeh42


2 Answers

After writing this question I came across the ConfigServiceProvider:

You can store your config data in json or yml files and access them through $app["name.of.config.var"].

Replacements to add values dynamically to the config files on setup are also supported. The only thing I did not manage so far is to inject the baseurl via the $app["request"] api into the config files.

like image 63
herrjeh42 Avatar answered Oct 17 '22 12:10

herrjeh42


I would store it in Silex\Application. It's a DI-container based on Pimple, so you can just do:

$app['baseUrl'] = '/';

Since $app pretty much gets passed around everywhere, you will also have access to this everywhere.

like image 27
Evert Avatar answered Oct 17 '22 11:10

Evert