Install Mongodb Driver For Php On Xampp For Mac

As we have seen in my earlier post that how to install and run mongodb on windows 10. 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.

If you don’t have xampp on your machine, please have a look on how to install xampp on windows 10.

Install Mongodb Driver For Php On Xampp For Mac Free

  1. In order to install PHP extensions like MongoDB via Homebrew. After tapping the formula repository, install the MongoDB extension brew install phpxx-mongodb where xx is the version number.
  2. Sep 20, 2015.
  3. Now open php.ini by clicking Config and then click on PHP(php.ini) in XAMPP control panel. Add extension=phpmongodb.dll in php.ini and save it. Restart XAMPP. Now again check PHP info. Now there will be a separate section for mongodb. If you didn’t find mongodb section in phpinfo then make sure you downloaded current mongodb driver zip. Now open cmd and start mongodb server my typing mongod command. Now create a mongo-test.php file in htdocs to check php and mongodb communication.
  4. 由于习惯了使用xampp进行开发,没有使用mac自带的 php 和 apache,简直是为安装 mongodb 扩展带来了极大的痛苦。但在钻研之下,最终还是找到了解决方案,在此做一下记录。 本次所使用的 xampp 版本是 XAMPP 7.3.1-0 其中 PHP 的版本为 7.3 macOS 版本:macOS Mojave 10.14.2.

Install and Configure XAMPP. First, you should install the XAMPP stack. Download and install the.

By default, PHP in XAMPP has no mongodb support. So we have to download mongodb extension from PECL (PHP extension repository) and configure it in xampp.

Install Mongodb Driver For Php On Xampp For Mac

So lets started.

Also Read:

Steps: Install Mongodb Driver for PHP 7 on XAMPP

  1. Check your current PHP version and also check that it is Thread Safe or not. My PHP version is 7.2 with thread safety enabled.
  2. Goto https://pecl.php.net/package/mongodb/1.5.3/windows and download driver according to your windows and php version. I am going to download 7.2 Thread Safe (TS) x86 because I have windows 10 64bit.
  3. After downloading zip file. Unzip that zip file and copy php_mongodb.dll to your xamppphpext directory.I have installed xampp in D: drive so my path will be D:xamppphpext.
  4. Now open php.ini by clicking Config and then click on PHP(php.ini) in XAMPP control panel.
  5. Add extension=php_mongodb.dll in php.ini and save it.
  6. Restart XAMPP.
  7. Now again check PHP info. Now there will be a separate section for mongodb. If you didn’t find mongodb section in phpinfo then make sure you downloaded current mongodb driver zip.
  8. Now open cmd and start mongodb server my typing mongod command.
  9. Now create a mongo-test.php file in htdocs to check php and mongodb communication.
  10. Now run mongo-test.php file from browser. If all goes well, you should get object.

Note: Default address of mongodb server is 127.0.0.1 and default port is 27017.

Test code: (mongo-test.php)