1 -The first step we need to sure we installed Mongodb in the global environment on the PC.
2 - Installation
if ready I will be run in my project this command
"$ composer require jenssegers/mongodb"
3-Laravel
In case your Laravel version does NOT autoload the packages, add the service provider to config/app.php:
Jenssegers\Mongodb\MongodbServiceProvider::class,
4- Configuration
You can use MongoDB either as the main database, either as a side database. To do so, add a new MongoDB connection to config/database.php:
'mongodb' => [
'driver' => 'mongodb',
'host' => env('MONGO_DB_HOST','localhost'),
'port' => env('MONGO_DB_PORT'),
'database' => env('MONGO_DB_DATABASE'),
'username' => env('MONGO_DB_USERNAME'),
'password' => env('MONGO_DB_PASSWORD'),
'options' => []
],
if need to used DSN :
'mongodb' => [
'driver' => 'mongodb',
'dsn' => env('MONGO_DB_DSN'),
'database' => env('MONGO_DB_DATABASE'),
]
5 - env File '.env'
MONGO_DB_HOST=127.0.0.1
MONGO_DB_PORT=27017
MONGO_DB_DATABASE={my_db}
MONGO_DB_USERNAME={my_user}
MONGO_DB_PASSWORD={my_password}
if need to used DSN :
MONGO_DB_DSN= {my_link_dsn}
Top comments (0)