As we have seen in my earlier post that how to install and run mongodb on windows 10<\/a>. But we didn’t see how mongodb will connect to php. I usually use xampp for my local development which have php 7.2 version. So we will be configuring mongodb on xampp to make it works. <\/p>\n If you don’t have xampp on your machine, please have a look on how to install xampp on windows 10<\/a>.<\/p>\n By default, PHP in XAMPP has no mongodb support. So we have to download mongodb extension from PECL (PHP extension repository)<\/a> and configure it in xampp.<\/p>\n So lets started.<\/p>\n Also Read:<\/p>\n Note: Default address of mongodb server is 127.0.0.1 and default port is 27017.<\/span><\/p>\n\n
Steps: Install Mongodb Driver for PHP 7 on XAMPP<\/h2>\n
\n
php_mongodb.dll<\/code> to your
xampp\\php\\ext<\/code> directory.I have installed xampp in
D:<\/code> drive so my path will be
D:\\xampp\\php\\ext<\/code>.<\/li>\n
php.ini<\/code> by clicking
Config<\/code> and then click on
PHP(php.ini)<\/code> in XAMPP control panel.<\/li>\n
extension=php_mongodb.dll<\/code> in
php.ini<\/code> and save it.<\/li>\n
mongod<\/code> command.<\/li>\n
mongo-test.php<\/code> file in
htdocs<\/code> to check php and mongodb communication.<\/li>\n
mongo-test.php<\/code> file from browser. If all goes well, you should get object.<\/li>\n<\/ol>\n
Test code: (mongo-test.php)<\/h3>\n
\r\n\r\n<\/pre>\n
\n