问题
I'm trying to get Laravel MongoDB working in my local machine (Windows 10 home, x64) by following this tutorial
- I have installed XAMPP 7.3.11 on
D:\xampp
succesfully and tested that the server can be reached (enterlocalhost:80
on browser) I proceeded on extracting
php_mongodb.dll
I got from pecl(mongodb 1.6.0 for Windows, 7.3 Non Thread Safe, x64 ) onD:\xampp\php\ext
and add the lineextension=php_mongodb.dll
on the fileD:\xampp\php\php.ini
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"
回答1:
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.
回答2:
There are many solution to resolve this error:
1) please change the extension=php_mongodb.dll
to extension=php_mongo.dll
.
2) If still error generated other solution is to download proper Dll
file. The reason behind this is we use 64 Bit supported DLL file 64 Bit system. But the wamp/xampp architecture could be 32 Bit. We need to use based on the wamp/xampp architecture not the windows architecture. So, try to find relevant version of DLL file to the wamp/xampp architecture.
Please try with these two solution.
来源:https://stackoverflow.com/questions/58968375/php-startup-unable-to-load-dynamic-library-php-mongodb-dll