Installing the MongoDB PHP Driver on Windows

Precompiled binaries are attached to the project's » Github releases. Archives are published for various combinations of PHP version, thread safety (TS or NTS), and architecture (x86 or x64). Determine the correct archive for your environment and extract the php_mongodb.dll file to the PHP extension directory ("ext" by default).

Add the following line to the php.ini file for each environment in which you intend to use the driver:


Failure to select the correct binary will result in an error when attempting to load the extension DLL at runtime:

PHP Warning:  PHP Startup: Unable to load dynamic library 'mongodb'

Ensure that you have downloaded a DLL that corresponds to the following PHP runtime properties:

  • PHP version (PHP_VERSION)
  • Thread safety (PHP_ZTS)
  • Architecture (PHP_INT_SIZE)

In addition to the aforementioned constants, these properties can also be inferred from phpinfo(). If your system has multiple PHP runtimes installed, double-check that you are examining the phpinfo() output for the correct environment.

Note: Additional DLL dependencies for Windows Users

In order for this extension to work, there are DLL files that must be available to the Windows system PATH. For information on how to do this, see the FAQ entitled "How do I add my PHP directory to the PATH on Windows". Although copying DLL files from the PHP folder into the Windows system directory also works (because the system directory is by default in the system's PATH), this is not recommended. This extension requires the following files to be in the PATH: libsasl.dll

add a note

User Contributed Notes 2 notes

luchontandil3 at gmail dot com
3 years ago
Try using:


instead and restarting the xammp server for php
also download the correct .dll for your version of php

you can check your version of php with index.php and inside adding

Xylon Reyes
6 years ago
With the newer version of MongoDB, this should be...


(the filename of the latest stable release at PECL)

Official MongoDB library are available at GitHub as well as its documentation.

Precompiled binaries are also available at GitHub for the legacy and the newer version.
To Top