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?
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With