I'm integrating MongoDB with Laravel. I'm following information found in this link jenssegers/laravel-mongodb. I'm successful at integrating MongoDB. But when I run the code it throws this error
FatalErrorException in Client.php line 56: Class 'MongoDB\Driver\Manager' not found
Here is the code
Controller app/Http/Controller/NewController
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\User;
class NewController extends Controller
{
//
public function index(){
$var = User::all();
var_dump($var);
}
}
And here follows the user.php
that is by default provided by Laravel when we create the project
<?php
namespace App;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
class User extends Eloquent
{
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $collection = 'users_collection';
protected $fillable = [
'name', 'email', 'password',
];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
}
Please tell me why am I getting this error.
Phpinfo --> mongodb section is coming. Here is a screen shot phpinfo
The official MongoDB Node. js driver allows Node. js applications to connect to MongoDB and work with data. The driver features an asynchronous API which allows you to interact with MongoDB using Promises or via traditional callbacks.
When you are going to connect MongoDB database with any PHP application then you can face this issue if you don't have PHP MongoDB driver.
So first you need to run following command to install Mongodb PHP extension :
sudo apt-get install php-mongodb
Now restart the server :
sudo service apache2 restart
reference from hdtuto
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With