Installing MongoDB driver for PHP on Windows

I’m currently using PHP Version 8.2.4 on Windows 10 I have tried this method by downloading the .dll file using Gthub and adding that .dll file to the inside the ext folder and then upgrade the php.ini file extension as well extension=php_mongo.dll. Still, it didn’t work.

Did you receive any error messages?

1 Like

when I try this I’m getting this warning.

I wonder if either your php.ini file has a typographical error in it, or of the dll itself was damaged in downloading?

1 Like

There wasn’t any error on the php.ini file and I downloaded the DLL file using the from the GitHub.

um … maybe file permissions on the dll?

Read & write and read permission was allowed.

What about execute permission? Does a .dll needs execute permission?

@Chanaka_Niroshana when installing DLLs for Windows, it is important to grab the correct file that corresponds to your PHP environment. This not only includes the PHP version itself, but also the architecture (x86 vs. x64) and thread safety. Quoting from our Windows DLL FAQ:

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)

We do provide a script that should help you detect the extension as part of the PHP library. You can grab a copy of it and run it locally: mongo-php-library/tools/detect-extension.php at master · mongodb/mongo-php-library · GitHub

The FAQ page I linked above contains some more information about the tool. Note that while the tool still refers to PECL for obtaining Windows DLLs, they are now published as part of our GitHub releases. I’ll make sure the tool is updated accordingly.

1 Like