I've probably spent more time than I should on this. I want to deploy PHP & mongodb applications with the help of Heroku.
Heroku mLab provides me the environment variable MONGODB_URI for accessing in PHP through getenv('MONGODB_URI') and this environment contains standard MongoDB URI:
mongodb://<dbuser>:<dbpassword>@dsxxxxxx.mlab.com:31899/heroku_lxxxxxx
which already contains an existing database name, but I have connected the string without it, as mentioned below:
$client = new MongoDB\Client("mongodb://localhost:27017");
$collection = $client->demo->beers;
So can I use the default Heroku's MONGODB_URI string or I have to parse_uri it and then pass that to PHP?