Answers for "connect mongodb with php"

PHP
0

connect mongodb with php

To use mongodb with php you have to use mongodb php driver. Kindly follow below to download the latest mongodb php driver.
https://s3.amazonaws.com/drivers.mongodb.org/php/index.html
After downloading unzip the file put php_mongo.dll into php extesion directory.
And add below line into your php.ini file
extension = php_mongo.dll
  
To test its working or not execute below line of code on browser
<?php
   // connect to mongodb
   $m = new MongoClient();
	
   echo "Connection to database successfully";
   // select a database
   $db = $m->mydb;
	
   echo "Database mydb selected";
?>
Posted by: Guest on June-27-2020

Browse Popular Code Answers by Language