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:

extension=php_mongodb.dll

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.

注意: Additional DLL dependencies for Windows Users

为了使此扩展生效, DLL 文件必须能在 Windows 系统的 PATH 指示的路径下找到。如何操作的信息,请参见题为“如何在 Windows 中将 PHP 目录加到 PATH 中”的FAQ。虽然将 DLL 文件从 PHP 文件夹复制到 Windows 系统目录也行,但不建议这样做。 此扩展需要下列文件在 PATH 路径中: libsasl.dll

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top