首页 > 解决方案 > PHP Startup: Unable to load dynamic library 'php_mongodb.dll'

问题描述

I'm trying to get Laravel MongoDB working in my local machine (Windows 10 home, x64) by following this tutorial

  1. I have installed XAMPP 7.3.11 on D:\xampp succesfully and tested that the server can be reached (enter localhost:80 on browser)
  2. I proceeded on extracting php_mongodb.dll I got from pecl(mongodb 1.6.0 for Windows, 7.3 Non Thread Safe, x64 ) on D:\xampp\php\ext and add the line extension=php_mongodb.dll on the file D:\xampp\php\php.ini

  3. After selecting 'the command-line PHP you want to use' to D:\xampp\php\php.exe, the setup then gave the following output:

    The PHP exe file you specified did not run correctly: D:\xampp\php\php.exe

    The php.ini used by your command-line PHP is: D:\xampp\php\php.ini

    A setting in your php.ini could be causing the problem: Either the 'extension_dir' value is incorrect or the dll does not exist.

    Program Output: PHP Warning: PHP Startup: Unable to load dynamic library 'php_mongodb.dll' (tried: D:\xampp\php\ext\php_mongodb.dll (The specified module could not be found.), D:\xampp\php\ext\php_php_mongodb.dll.dll (The specified module could not be found.)) in Unknown on line 0

Commenting out the line extension=php_mongodb.dll will execute D:\xampp\php\php.exe without any warning. But I would need php to be aware of php_mongodb.dll during composer installation, right?

So how to resolve this problem? The file definitely exists in the folder, and the required modification on php.ini has been provided. I have already looked around and some people mentioning the path in extension_dir must be written in full path. But I have already checked that the line on my php.ini is extension_dir="D:\xampp\php\ext"

标签: phplaravelmongodbxamppcomposer-php

解决方案


Problem resolved.

Cause: I was using Non Thread Safe php_mongodb.dll, while the PHP installed by XAMPP is a Thread Safe one.

After replacing php_mongodb.dll with the thread safe version, there's no error and I can successfully completed composer installation.


推荐阅读