Skip to content

Instantly share code, notes, and snippets.

@eichgi
Created July 5, 2020 18:31
Show Gist options
  • Select an option

  • Save eichgi/0902feb303f46582aaacf21697d6861b to your computer and use it in GitHub Desktop.

Select an option

Save eichgi/0902feb303f46582aaacf21697d6861b to your computer and use it in GitHub Desktop.
#Extensive definition
'mongodb' => [
'driver' => 'mongodb',
'host' => env('MONGO_HOST', 'localhost'),
'port' => env('MONGO_PORT', 27017),
'database' => env('MONGO_DATABASE', 'default'),
'username' => env('MONGO_USERNAME', ''),
'password' => env('MONGO_PASSWORD', ''),
'options' => [
// here you can pass more settings to the Mongo Driver Manager
// see https://www.php.net/manual/en/mongodb-driver-manager.construct.php under "Uri Options" for a list of complete parameters that you can use
'retryWrites' => env('MONGO_RETRY_WRITES', false),
'replicaSet' => env('MONGO_REPLICASET', 'rs-dsxxxxxx'),
'database' => env('DB_AUTHENTICATION_DATABASE', 'admin'), // required with Mongo 3+
],
],
#DSN definition (Mongo Atlas for example)
'mongoatlas' => [
'driver' => 'mongodb',
'dsn' => "mongodb+srv://" . env("MONGO_USERNAME") . ":" . env("MONGO_PASSWORD") . "@clusterxxxxxx.xxxxx.mongodb.net/" . env("MONGO_DATABASE") . "?retryWrites=true&w=majority",
'database' => env('MONGO_DATABASE', 'mongo'),
'options' => [
// here you can pass more settings to the Mongo Driver Manager
// see https://www.php.net/manual/en/mongodb-driver-manager.construct.php under "Uri Options" for a list of complete parameters that you can use
'database' => env('DB_AUTHENTICATION_DATABASE', 'admin'), // required with Mongo 3+
],
],
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment