How to install mongoDB PHP driver on windows ?

Created at 17-Mar-2024 , By samar

The MongoDB PHP driver is a software library that provides a set of functions for communicating with a MongoDB database from PHP. It allows you to perform a wide range of operations on a MongoDB database, including inserting, updating, and deleting data, as well as reading and querying data.

To use the MongoDB PHP driver, you will need to install it on your system and enable it in your PHP configuration. Once the driver is installed and enabled, you can use it in your PHP scripts by including the appropriate library files and using the provided functions to connect to a MongoDB database and perform operations on it.

Download PHP MongoDB Driver

To install the PHP MongoDB driver from the PECL website, you should first visit the URL and select the desired package. There are many versions of the MongoDB driver available on the PECL website. You have to choose the stable version because alpha and beta versions of software are those that are still in the development and testing phase.

download php mongodb driver!

After clicking on the DLL (highlighted in above image) you will be redirected to the next page.

Now you have to download the appropriate file that matches the PHP version and configuration of your system. It will download a .zip file. That needs to be extracted. After you have extracted the contents of the file, you will need to locate the .dll file.


Copy PHP MongoDB DLL file to EXT Directory

Copy the “php_mongodb.dll” file and paste it into the “ext” directory located at “C:\xampp\php\ext” ( Assuming that you are using xampp server installed in C drive).

For laragon users, “ext” directory is located at “C:\laragon\bin\php\php-8.1.10-Win32-vs16-x64\ext“. Your PHP version may be different so you can paste the .dll file as per your requirement.

Add Extension to php.ini

Open php.ini file located in “C:\xampp\php\php.ini”. Add the following line in the php.ini file.


If you are using the Laragon server your php.ini file will be located in the C:\laragon\bin\php\php-8.1.10-Win32-vs16-x64\ directory.

Restart Server

Once you have added extension=php_mongodb.dll to your php.ini file, save the file and restart your web server to make the changes take effect. The MongoDB extension should now be enabled and available to use in your PHP scripts.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Buy Me A Coffee

Don't forget to share this article! Help us spread the word by clicking the share button below.

We appreciate your support and are committed to providing you valuable and informative content.

We are thankful for your never ending support.