I want to configure both MySQL and MongoDB connections in my .env file in Laravel. How can I set the following parameters for both:
DB_CONNECTION=
DB_HOST=
DB_PORT=
DB_DATABASE=
DB_USERNAME=
DB_PASSWORD=.
I want to configure both MySQL and MongoDB connections in my .env file in Laravel. How can I set the following parameters for both:
DB_CONNECTION=
DB_HOST=
DB_PORT=
DB_DATABASE=
DB_USERNAME=
DB_PASSWORD=.
2
Answers
You can define new env variables and create a new connection for mongoDB in
config/database.php
:in your .env:
in
config/database.php
:don’t forget to run
php artisan config:cache
after make these changes.