After executing the previous commands, you have to make a change in your php.ini file. Open the file in your favorite text editor and extension_dir variable is pointing to the location of mongo.so. Also, add 'extension=mongo.so' in a file, save and restart your web server.

Now if you point your browser to a php file containing 'echo phpinfo();' command, you can see that in the output, MongoDB is shown as installed.

Install MongoDB PHP driver on Windows

Pre compiled binaries are available on github. Download the version compatible with your PHP and MongoDB version. Before you select to download a specific binary, remember the following :

Opt for VC6 if you are running Apache web server.

Opt for 'Thread safe' if you are running PHP as an Apache module, but if you are running PHP as CGI, go for ' non-thread safe'.

Opt for VC9 if you are running IIS web server.

After you download the binary suitable for you, unzip it and add 'php_mongo.dll' file to your PHP extension directory, which usually located as 'ext' folder within your PHP installation directory.

Open your 'php.ini' file and add 'extension=php_mongo.dll' to it.

Restart your web server.

Now if you point your browser to a php file containing 'echo phpinfo();' command, you can see that in the output, MongoDB is shown as installed.

Install MongoDB PHP driver on Mac

You can install MongoDB PHP driver using 'autoconf'.

You can install MongoDB PHP driver using 'Xcode'.

If you are using XAMPP, you may install MongoDB PHP driver using the following command :

sudo /Applications/XAMPP/xamppfiles/bin/pecl install mongo

If the above command does not work on XMPP or MAMP, you have to download the compatible precompiled binary from github. You have to add 'extension=mongo.so' to your php.ini file and restart your web server.