Error "Class 'Mongodb Driver Manager' not found"

Asked

Viewed 2,570 times

4

At the time of use of the Mongodb, along with the Laravel it returns the following error:

Fatalerrorexception in Client.php line 61: Class 'Mongodb Driver Manager' not found

  • You edited the Laravel database.php ?

  • http://haafiz.me/development/using-laravel-with-mongodb

  • Already followed this tutorial and nothing

  • Driver is installed on the Server ?

  • It is , but I suspect that the error may be on the server , because Mongo is active but does not appear in phpinfo

2 answers

4

There are currently two drivers for Mongodb: Mongo and the mongodb.

The mongo is legacy. Already the mongodb is more current, works with more current versions of PHP, in addition to working with HHVM and other things. In the rewriting of the new driver, among other changes, all classes were rewritten and namespaces changed.

Based on your mistake of Class 'MongoDB\Driver\Manager' not found it is possible to infer that the library for Mongodb that you are trying to use in conjunction with Laravel, uses the newest version of the driver, the mongodb.

The newest version can be installed with pecl. After this installation, this error should stop occurring.

  • It should come with the Driver Module in the library installed by Composer, as with Exception and Operation in the Client class. All are in the vendor, except the Driver. The error is in Mongodb Driver Manager within the class itself. This does not allow her to search for something in the OS, but in her namespace. There is a difference between legacy (Mongo) and mongodb, but there is another problem. In my case, my Poser.json is like mongodb/mongodb:1. *, so it should bring all the content, including the namespace Driver. Giving problem in conjunction with Mongo.so, it’s another story.

2

No problem in Laravel, it’s missing the Mongodb module in PHP.

Note that there are two versions of the module /a/143674/3635

To install the Mongodb module you will need:

Install by PECL:

sudo pecl install mongodb

And then add in php.ini this:

extension=mongodb.so

If it’s Windows, download the Thread Safe version at http://pecl.php.net/package/mongodb

Extract the php_mongodb.dll and copy into the folder extensions/ and then add to php.ini:

extension=php_mongodb.dll

Downloading Mongodb from Github

You can try manual installation via Git, however you will need to compile, however you need to install the phpize first, if it is Debian or Ubuntu (or based on it) use the PHP5 command:

sudo apt-get install php5-dev

If php7.0, 7.1, 7.2 (and futures) use:

sudo apt-get install php7.0-dev

Or:

sudo apt-get install php7.1-dev

Or:

sudo apt-get install php7.2-dev

Then after installing (and having installed Git) run the commands:

git clone https://github.com/mongodb/mongo-php-driver.git
cd mongo-php-driver
git submodule sync && git submodule update --init
phpize
./configure
make all -j 5
sudo make install

It is possible to compile in Windows using Visual Studio as well, but it is necessary to download in https://windows.php.net/downloads/releases/ php-devel, for example:

php-devel-pack-5.6.37-nts-Win32-VC11-x64.zip
php-devel-pack-5.6.37-nts-Win32-VC11-x86.zip
php-devel-pack-5.6.37-Win32-VC11-x64.zip
php-devel-pack-5.6.37-Win32-VC11-x86.zip
php-devel-pack-7.0.31-nts-Win32-VC14-x64.zip
php-devel-pack-7.0.31-nts-Win32-VC14-x86.zip
php-devel-pack-7.0.31-Win32-VC14-x64.zip
php-devel-pack-7.0.31-Win32-VC14-x86.zip
php-devel-pack-7.1.21-nts-Win32-VC14-x64.zip
php-devel-pack-7.1.21-nts-Win32-VC14-x86.zip
php-devel-pack-7.1.21-Win32-VC14-x64.zip
php-devel-pack-7.1.21-Win32-VC14-x86.zip
php-devel-pack-7.2.9-nts-Win32-VC15-x64.zip
php-devel-pack-7.2.9-nts-Win32-VC15-x86.zip
php-devel-pack-7.2.9-Win32-VC15-x64.zip
php-devel-pack-7.2.9-Win32-VC15-x86.zip

Choose according to your Visualstudio and PHP version.


Installing Mongodb at HHVM

If you’re using HHVM then you have to download via Git:

git clone https://github.com/mongodb/mongo-hhvm-driver.git
cd mongo-hhvm-driver
git submodule sync && git submodule update --init --recursive
hphpize
cmake .
make configlib
make -j 5
sudo make install

After any of these processes you may have to restart Apache (or HHVM)

Documentation: http://php.net/manual/en/mongodb.installation.php

Browser other questions tagged

You are not signed in. Login or sign up in order to post.