filmov
tv
Laravel MongoDB Tutorial #2 | Connect Laravel 10 Project with MongoDB

Показать описание
In Part 2 of the Laravel MongoDB Tutorial, we will connect Laravel with MongoDB. Laravel we will use for the front end and MongoDB we are going to use as the backend for our website database.
Pre Requirements:
Install Xampp or Wamp Server
Install Composer
1) Create Laravel 10 Project
Run the composer command to create the Laravel 10 project
composer create-project laravel/laravel test-mongodb
2) Install MongoDB Package for Laravel
Install the MongoDB Package for Laravel by running the below composer command:
composer require mongodb/laravel-mongodb
4) Update .env file:-
Now, update the .env file to connect with the MongoDB database. Update DB_CONNECTION as mongodb, DB_DATABASE as your database name like laravelmongo in our case and DB_URI as mongodb://localhost:27017
DB_CONNECTION=mongodb
DB_HOST=127.0.0.1
DB_PORT=27017
DB_DATABASE=laravelmongo
DB_USERNAME=
DB_PASSWORD=
DB_URI=mongodb://localhost:27017
5) Run "php artisan migrate"
Run the "php artisan migrate" command to add default auth tables like users in laravelmongo database.
6) Test at MongoDB Compass:-
Finally, test at MongoDB Compass to check if all the default collections including the users collection added to the laravelmongo database.
Popular Stack Developers Series that can help you:-
►Join this channel to get the complete source code of all series:
Follow Stack Developers on Social Media to get updates and resolve your queries
#mongodb #mongodbtutorial #mongodbtutorialforbeginners
Комментарии