I would like to retrieve the password currently used by a doctrine2 dbal connection, in symfony2.
If I use $kernel->getContainer()->getParameter('database_password'), I can find the one defined in parameters.yml but if I define different password for some environments (in config_test.yml for example), the data from parameters.yml is useless.
Now if I look thru $kernel->getContainer()->getParameterBag()->all(), I still cannot find it.
And in case you wonder why? I am using a lock mechanism in a function, and I am trying to use register_shutdown_function() to remove that lock in case there is a fatal error, using php built-in mysql or pdo function since at that point, most of the framework is down.
If you cannot retrieve it, then you will not have a DB connection either.
Parameters from test environment won’t be loaded in the dev, prod, … environment!
In case of overriding, define all your connection parameters in parameters.yml
Same goes for all other environments your using.