我在尝试在 PHP 中使用 MongoDB 扩展时遇到问题。
我使用以下命令安装 MongoDB PHP 库:
composer require mongodb/mongodb
但是,我收到以下错误:
PHP Warning: PHP Startup: Unable to load dynamic library 'mongodb' (tried: C:\xampp\php\ext\mongodb (The specified module cannot be found), C:\xampp\php\ext\php_mongodb.dll (The specified module cannot be found)) in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library 'mongodb' (tried: C:\xampp\php\ext\mongodb (The specified module cannot be found), C:\xampp\php\ext\php_mongodb.dll (The specified module cannot be found)) in Unknown on line 0
Cannot use mongodb/mongodb's latest version 1.19.1 as it requires ext-mongodb ^1.18.0 which is missing from your platform.
该错误表明缺少 ext-mongodb 扩展,但我已经采取了以下步骤:
下载 PECL 扩展: php_mongodb-1.19.3-8.2-ts-vs16-x64.zip
提取 php_mongodb.dll 文件并将其移动到: C:\xampp\php xt
将以下行添加到我的 php.ini 文件中: 扩展名=mongodb
我也尝试过: 扩展名=php_mongodb.dll 扩展名=“C:/xampp/php/ext/mongodb”
重新启动Apache,但仍然遇到同样的错误。
附加信息: php -i 的输出:
PHP Version => 8.2.12
Thread Safety => enabled
Architecture => x64
预期结果: 成功加载 MongoDB 扩展,以便我可以在我的 PHP 项目中使用 MongoDB 库。
实际结果: 仍然存在以下错误:
PHP Warning: PHP Startup: Unable to load dynamic library 'mongodb' (tried: C:\xampp\php\ext\mongodb (The specified module cannot be found), C:\xampp\php\ext\php_mongodb.dll (The specified module cannot be found)) in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library 'mongodb' (tried: C:\xampp\php\ext\mongodb (The specified module cannot be found), C:\xampp\php\ext\php_mongodb.dll (The specified module cannot be found)) in Unknown on line 0
我做错了什么,如何解决这个问题?