Problem: When using the mongor
bundle for Laravel, I get an error Class 'Mongo' not found
. Any ideas what went wrong?
I installed mongodb and started the mongodb service. Next I installed the mongor bundle and created/updated the following files.
php artisan bundle:install mongor
bundles.php
return array(
'docs' => array('handles' => 'docs'),
'mongor' => array('auto' => true),
);
database.php
'default' => 'mongor',
'mongor' => array(
'hostname' => 'localhost',
'connect' => true,
'timeout' => '',
'replicaSet' => '',
'db' => 'test',
'username' => '',
'password' => '',
),
user.php
<?php
class User extends Mongor\Model {}
routes.php
Route::get('test', function() {
$user = User::find(1);
});
ERROR
Class 'Mongo' not found
Location: /var/www/test/bundles/mongor/mongodb.php on line 85
Line causing error
$this->_connection = new \Mongo($conn, $options);
The problem is that you don't have a driver installed.
In order to connect to MongoDB you must have the PHP driver which will allow you to communicate to MongoDBs interface.
You cna find the installation guide in the PHP manual ( http://php.net/manual/en/mongo.installation.php ) or on the MongoDB website ( http://docs.mongodb.org/ecosystem/drivers/php/ ).
Make sure to start MongoDB with auth turned off for your case.