Laravel with MongoDB CURD operations - part 1

First you need to install Laravel and MongoDB.

I assume you have already know how to install Laravel.

Will start from MongoDb install.

Follow the mongodb official documentation and install MongoDB according to your OS
https://docs.mongodb.com/manual/installation/

We need to add MongoDB extention to php next.
For do that add the following line to php.ini file
extension=php_mongodb.dll
Restart the server.

Now we are ready to start with Laravel.

First you need to give the information for your .env file

DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=yourdatabasename

Add this on your config/database.php file

'mongodb' => [
            'driver'   => 'mongodb',
            'host'     => env('DB_HOST', 'localhost'),
            'port'     => 27017,
            'database' => env('DB_DATABASE', 'test'),
          ],
You can add username and password.This post I skip the adding user name and password.

Now your ready.
In next post will create page to add data to the database.










Comments