Use environment variables as Symfony parameters

I had a case where I wanted to store a configuration into a vhost environment variable. But how to get this into your symfony parameters? There is a special environment variable prefix in Symfony which will automatically be converted into a parameters variable. It is SYMFONY__.

The prefix will be stripped, the variable name will be converted to lowercase and a double underscore __ will be converted to a dot . as this is an invalid character in an environment variable.

So the following environment variable


will become the following parameter variable

mybundle.username: "liplex"  
comments powered by Disqus