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

2022-01-14 00:00:00 mongodb xampp php laravel composer-php

我正在尝试按照 本教程

  1. 我已经在D:xampp上成功安装了XAMPP 7.3.11,并测试可以访问服务器(在浏览器上输入localhost:80)
  2. 我继续提取 php_mongodb.dll 我从 D:xamppphpext 上的 "nofollow noreferrer">pecl(mongodb 1.6.0 for Windows, 7.3 Non Thread Safe, x64 ) 并添加行 extension=D:xamppphpphp.ini

  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:xamppphpext and add the line extension=php_mongodb.dll on the file D:xamppphpphp.ini

选择你想使用的命令行PHP"到D:xamppphpphp.exe后,安装程序给出以下输出:

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

您指定的 PHP exe 文件没有正确运行:D:xamppphpphp.exe

The PHP exe file you specified did not run correctly: D:xamppphpphp.exe

你的命令行 PHP 使用的 php.ini 是:D:xamppphpphp.ini

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

您的 php.ini 中的设置可能会导致问题:'extension_dir' 值不正确或 dll 不存在.

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

程序输出:PHP 警告:PHP 启动:无法加载动态库php_mongodb.dll"(尝试:D:xamppphpextphp_mongodb.dll(指定的模块无法找到.),D:xamppphpextphp_php_mongodb.dll.dll(指定的模块可以未找到.))在第 0 行的未知中

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

注释掉 extension=php_mongodb.dll 行将执行 D:xamppphpphp.exe 而没有任何警告.但是我需要 php 在作曲家安装期间了解 php_mongodb.dll ,对吗?

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

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

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:xamppphpext"

推荐答案

问题已解决.

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

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

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

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

相关文章