Fatal error: Class 'MongoDB\Driver\Manager' not found

后端 未结 7 817
攒了一身酷
攒了一身酷 2020-12-01 18:52

I want to use the MongoDB Driver, but it throw me an error, when i use it:

$mongo = new MongoDB\\Driver\\Manager(\"mongodb://localhost:27017\");
相关标签:
7条回答
  • 2020-12-01 19:29

    This error is because of php_mongodb.dll file is missing in the etc folder and add to the php.ini file like(extension=php_mongodb.dll) . Because of this I got this error. It will rectify my error

    0 讨论(0)
  • 2020-12-01 19:32

    If you get this error, even after you installed the Mongodb driver for php, just install mongodb using composer.

    composer require mongodb/mongodb
    

    After that this will solve your problem.

    0 讨论(0)
  • 2020-12-01 19:36

    1.Add mongo DB

    $sudo apt update && sudo apt install php-mongodb
    
    1. Restart apache server,

    2. check in phpinfo() for mongo

    0 讨论(0)
  • 2020-12-01 19:41

    There is some confusion between the Mongo extension and the MongoDB extension which are not the same. Because of your version number, I guess you are using the old Mongo extension that is deprecated.

    Make sure that you install the new MongoDB extension and you should be fine. Don't forget to remove the old extension=mongo.so from your php.ini since this could cause problems.

    0 讨论(0)
  • 2020-12-01 19:43

    Might be your CLI version of php is different ,check php version in terminal using php -v. and then switch accordingly... FOR EX-:

    From PHP 7.1 => PHP 5.6

    $ sudo update-alternatives --set php /usr/bin/php5.6.
    

    I hope it will help you guys.

    0 讨论(0)
  • 2020-12-01 19:47

    For me, I forgot to add extension=mongodb.so to the php.ini for FPM (FastCGI Process Manager). On Ubuntu 16.04 this was at:

    /etc/php/7.0/fpm/php.ini

    For what it's worth I'm using nginx.

    0 讨论(0)
提交回复
热议问题