I would like to use Symfony2 and MongoDB on a cloudControl (PaaS provider like heroku) container. Now Symfony2 supports the usage of MongoDB:
# app/config/config.yml
doctrine_mongodb:
connections:
default:
server: mongodb://localhost:27017
options: {}
default_database: test_database
document_managers:
default:
auto_mapping: true
And as MongoDB is a PaaS AddOn, I don't have static connection credentials. They're generated by the container. cloudControl offers this way to access the credentials in PHP:
$credfile = file_get_contents($_ENV['CRED_FILE'], false);
$credentials = json_decode($credfile, true);
$uri = $credentials["MONGOLAB"]["MONGOLAB_URI"];
$m = new Mongo($uri);
$db = $m->selectDB(myDbName);
$col = new MongoCollection($db, myCollection);
How can I get these dynamically fetched credentials into Symfony2's config.yml
?