Laravel 4: Class 'MongoClient' not found

I have Laravel 4 installed on WAMP and it works fine with the MySQL backend.

I have successfully configured a second virtual host and would like to use a backend MongoDB. After searching, I found out that Laravel is not connecting to MongoDB, and I found https://github.com/jenssegers/Laravel-MongoDB , and I tried to configure it, but I can't seem to be correct. Obviously, I have to do something wrong, and I hope that someone can help me determine what it is that I am wrong.

I edited composer.jsonaccording to the instructions:

............
"license": "MIT",
"require": {
    "laravel/framework": "4.1.*",
    "jenssegers/mongodb": "*"
},
"autoload": {
.........

Then I launched composer update. He installed monolog 1.9.1 and swiftmailer v5.2.0 - whatever it was - successfully (a few days ago), but then made a mistake after that. Today I tried to run again composer update, and it updated two to 1.10.0 and v5.2.1 respectively, and then ran into the same error. Now when I try composer update, it successively produces the same error:

Nothing to install or update
Generating autoload files
{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","me
ssage":"Class 'MongoClient' not found","file":"C:\\wamp\\www\\laravel\\vendor\\j
enssegers\\mongodb\\src\\Jenssegers\\Mongodb\\Connection.php","line":132}}Script
 php artisan clear-compiled handling the post-update-cmd event returned with an
error  


  [RuntimeException]
  Error Output:    


update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock]
 [--no-plugins] [--no-custom-installers] [--no-scripts] [--no-progress] [--with-
dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [packages1] ... [
packagesN]

What I tried :

I downloaded and installed php_mongo.dll, placing it in the php ext folder and including it in php.ini:

; added for mongoDB connections
extension=php_mongo.dll

But it did not help.

+4
source share
2 answers

NOTE: I would not be able to completely solve the problem without the help of @Hassan - see comments in response to @Hassan.

, - , . , , .

: https://github.com/jenssegers/Laravel-MongoDB/issues/36 : https://github.com/leroy-merlin-br/mongolid-laravel#troubleshooting
php.ini, php_mongo.dll:

$ php -i | grep 'Configuration File'
Configuration File (php.ini) Path => C:\Windows
Loaded Configuration File => C:\wamp\bin\php\php5.5.12\php.ini

WAMP, , C:\wamp\bin\apache2.4.9\bin\php.ini - , . , PHP CLI , :

$ php -i | grep 'Mongo'
MongoDB Support => enabled

php.ini, restarted apache composer update. - - , . , - .

+8

, , , . " dumpautoload", :

- classmap, , "dump-autoload" , .

, app/config/database.php, mongodb :

'default' => 'mongodb',

mongodb :

'connections' => array(
...
    'mongodb' => array(
        'driver'   => 'mongodb',
        'host'     => 'localhost',
        'port'     => 27017,
        'username' => '',
        'password' => '',
        'database' => 'test'
    ),
),
+3

Source: https://habr.com/ru/post/1544810/


All Articles