douchui1657 2018-08-13 22:26
浏览 390
已采纳

未找到“MongoDB \ Driver \ Manager”类(扩展未加载)

I'm aware that there are other questions similar to this one, but none of them have solutions to the exact problem that I'm having.

I've installed the mongodb php driver, added the dll to xampp/htdocs/ext, and editted php.ini to include the new extension. However, when I try to run this php:

<?php
$connection = new MongoDB\Driver\Manager("mongodb://localhost:27017");
$db = $connection->lotus;
$users = $db->users;
$document = array(
    "username"=>"firstuser",
    "password"=>"firstpass"
);
$users->insert($document);
?>

I get the error: Fatal error: Uncaught Error: Class 'MongoDB\Driver\Manager' not found in C:\xampp\htdocs\testproject\index.php:2 Stack trace: #0 {main} thrown in C:\xampp\htdocs\testproject\index.php on line 2

A post on this same issue says that they confirmed that the extension was loaded using the following code:

echo extension_loaded("mongo") ? "loaded
" : "not loaded
"

However, I always receive "not loaded" as the output. Not sure exactly what I'm doing wrong here. Any ideas?

EDIT

The current php version is 7.2.8. I also found this error message when I checked the php version: PHP Warning: PHP Startup: Unable to load dynamic library 'php_mongodb.dll' (tried: \xampp\php\ext\php_mongodb.dll (%1 is not a valid Win32 application.) This seems to be the source of the problem.

Solution has been found - see below

  • 写回答

1条回答 默认 最新

  • dream5694 2018-08-13 23:04
    关注

    Solution: I was using a 64-bit dll which was incompatible with the 32-bit xampp which was running php. Simply remove the 64-bit dll and download the 32-bit version.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog