From 0e5e6ab68da99d2b60406e2757cba79021dcab77 Mon Sep 17 00:00:00 2001 From: "iVampireSP.com" Date: Wed, 14 Sep 2022 21:27:27 +0800 Subject: [PATCH] add mongodb --- .env.example | 7 +++++++ bootstrap/app.php | 3 +++ config/database.php | 15 +++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/.env.example b/.env.example index d42b6d5..980b6a2 100644 --- a/.env.example +++ b/.env.example @@ -21,6 +21,13 @@ DB_DATABASE=homestead DB_USERNAME=homestead DB_PASSWORD=secret +MONGO_DB_HOST=127.0.0.1 +MONGO_DB_PORT=27017 +MONGO_DB_DATABASE=homestead +MONGO_DB_USERNAME=homestead +MONGO_DB_PASSWORD=secret +MONGO_DBDB_AUTHENTICATION_DATABASE=admin + LARAVELS_LISTEN_IP=127.0.0.0 ALIPAY_APP_ID= diff --git a/bootstrap/app.php b/bootstrap/app.php index e53923e..a11bbe2 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -115,6 +115,9 @@ // $app->register(App\Providers\EventServiceProvider::class); $app->register(\Anik\Form\FormRequestServiceProvider::class); $app->register(App\Providers\RouteBindingServiceProvider::class); + +$app->register(Jenssegers\Mongodb\MongodbServiceProvider::class); + /* |-------------------------------------------------------------------------- | Load The Application Routes diff --git a/config/database.php b/config/database.php index 97252e3..f261a58 100644 --- a/config/database.php +++ b/config/database.php @@ -65,6 +65,21 @@ 'search_path' => env('DB_SCHEMA', 'public'), 'sslmode' => env('DB_SSL_MODE', 'prefer'), ], + + 'mongodb' => [ + 'driver' => 'mongodb', + 'host' => env('MONGO_DB_HOST', '127.0.0.1'), + 'port' => env('MONGO_DB_PORT', 27017), + 'database' => env('MONGO_DB_DATABASE', 'homestead'), + 'username' => env('MONGO_DB_USERNAME', 'homestead'), + 'password' => env('MONGO_DB_PASSWORD', 'secret'), + '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('MONGO_DBDB_AUTHENTICATION_DATABASE', 'admin'), // required with Mongo 3+ + ], + ], ], /*