Are you sure you have correct mongo driver installed? Because there is two, mongo and mongodb
Connecting to MongoDB with Lumen Framework
Hello, I am running Lumen in Homestead and MongoDB on my local machine and wondering how do I connect to MongoDb on my local machine. I get an error saying
Class 'MongoDB\Driver\Manager' not found
I am using jenssegers/laravel-mongodb and I also have the php mongo driver installed. Running PHP7.0, Here is my files:
userModel.php
<?php namespace App;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
class userModel extends Eloquent {
protected $connection = 'mongodb';
protected $collection = 'DATABASE_USERS';
protected $primaryKey = '_id';
}
?>
UsersController.php
<?php
namespace App\Http\Controllers;
use App\userModel;
class UsersController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
}
public function index() {
return userModel::all();
}
}
database.php
<?php
return [
'default' => 'mongodb',
'connections' => [
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', ''),
'username' => env('DB_USERNAME', ''),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
'mongodb' => array(
'driver' => 'mongodb',
'host' => env('MONGODB_HOST', 'localhost'),
'port' => env('MONGODB_PORT', 27017),
'username' => env('MONGODB_USERNAME', ''),
'password' => env('MONGODB_PASSWORD', ''),
'database' => env('MONGODB_DATABASE', 'DATABASE_USERS'),
'options' => array(
'db' => env('MONGODB_AUTHDATABASE', '')
)
),
],
];
?>
I also have the settings that is required in bootstrap/app.php and calling the index() function in routes.
@elfeffe I am using mongodb
@willvincent I figured it out and I am running mongodb in my virtual machine.
Please or to participate in this conversation.