Php MongoDB Connectivity
Php provides mongodb driver to connect with mongoDB database. After installing it, we can perform database operations by using the php. Here, we are using Ubuntu 16.04 to create an example. This example includes the following steps.
1) Installing Driver
2) Edit php.ini File
It is store in the apache server directory /etc/php/7.0/apache2/php.ini
3) Install mongo-php library
Following is the preferred way of installing this library with Composer.
4) Create Php Script
5) Execute Php Script
Execute this script on the localhost server. It will create database and store data into the mongodb.
6) Enter into Mongo Shell
After executing php script, we can see the created database in mongodb.
6.1. Show Database
The following command is used to show databases.
6.2. Show Collection
The following command is used to show collections.
6.3. Access Records
Well all set, this is working fine. We can also perform other database operations as well.