如何在PHP中安装Mongodb驱动程序

I followed the steps mentioned here https://www.youtube.com/watch?v=9gEPiIoAHo8.

I downloaded the latest stable version of it here https://pecl.php.net/package/mongodb which is 1.3.4. Extracted the php_mongodb.dll and placed it in the ext in my xampp directory. Modified the php.ini and added extension=php_mongodb.dll. Downloaded the composer but just when the composer installer does its work, it gives me the error.

I tried the x64 TS (I checked my phpinfo and its thread safe) because my laptop is 64 bit but it gives me an error

Program Output: PHP Warning: PHP Startup: Unable to load dynamic library 'C:\xampp\php\ext\php_mongodb.dll' - %1 is not a valid Win32 application. in Unknown on line 0

Tried the x84 as well (i know it wont work but i tried nontheless) and it gives me an error

The ordinal 4694 could not be located in the dynamic link library C:\xampp\php\ext\php_mongodb.dll

Followed by another pop-up after the mentioned error above

PHP Startup: Unable to load dynamic library C:\xampp\php\ext\php_mongodb.dll - The operating system cannot run %1

My PHP Version is PHP Version 5.6.3

Xampp Version v3.2.1 Compiled May 7th 2013

I tried other mongoDB php driver php_mongo.dll, it works fine and is loaded when i do php_info. I wanted to use the php_mongodb.dll since the other is depreciated.

  1. Download the mongo driver for Windows from pecl.php.net
    Download the latest stable release by clicking on the DLL link. On the next page there is a DLL list. Make sure to pick the correct one depending on:

    • the PHP version that is installed with your XAMPP,
    • Architecture x86 or x64,
    • whether Thread Safety is enabled or disabled.
      When Thread Safety is enabled, you need to download Thread Safe (TS) version.
  2. Unzip the downloaded mongo driver version and copy .dll file to XAMPP. After the successful download, unzip and find the .dll file. Copy it to the ext directory of your XAMPP installation. If you installed XAMPP to C drive, the full path to the ext folder would be C:\xampp\php\ext

  3. Register the mongodb.dll file within php.ini Add the following line into php.ini file:

    extension=php_mongodb.dll

  4. Restart XAMPP and refresh the phpinfo.php page When you restart XAMPP and refresh the phpinfo page, click CTRL+F and type mongodb, you should find infos about the just installed MongoDB Driver.

  5. Install MongoDB on Windows

Note, this is quite similar to that what you did. It is essential to match the dependencies. This process worked for me several times already.