PHP启动:无法加载动态库'php_mongodb.dll'

PHP Startup: Unable to load dynamic library 'php_mongodb.dll'

我正在尝试通过以下 this tutorial

让 Laravel MongoDB 在我的本地机器(Windows 10 home,x64)上工作
  1. 我已经在D:\xampp上成功安装了XAMPP 7.3.11并测试可以访问服务器(在浏览器中输入localhost:80
  2. 我继续从 pecl 中提取 php_mongodb.dll(mongodb 1.6.0 for Windows,7.3 非线程安全,x64)在 D:\xampp\php\ext 上并在文件 D:\xampp\php\php.ini

  3. 上添加行 extension=php_mongodb.dll
  4. 选择 'the command-line PHP you want to use' 到 D:\xampp\php\php.exe 后,设置程序给出以下输出:

    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

注释掉行 extension=php_mongodb.dll 将在没有任何警告的情况下执行 D:\xampp\php\php.exe。但是我需要 php 在 composer 安装期间知道 php_mongodb.dll,对吗?

那么如何解决这个问题呢?该文件肯定存在于文件夹中,并且已提供 php.ini 上所需的修改。 我已经环顾四周,有些人提到 extension_dir 中的路径必须写成完整路径。但是我已经检查过 php.ini 上的行是 extension_dir="D:\xampp\php\ext"

问题已解决。

原因:我使用的是非线程安全 php_mongodb.dll,而 XAMPP 安装的 PHP 是线程安全的。

php_mongodb.dll替换为线程安全版本后,没有报错,可以顺利完成composer安装。