Have you installed the Mongodb extension?
Mar 11, 2018
5
Level 1
Getting Laravel and Homestead to work with MongoDB
Hi all, I'm getting a quite frustrated by how hard it seems to be to set up MongoDB with Laravel.
So far I have installed the MongoDB composer package to my project:
https://packagist.org/packages/mongodb/mongodb
I have also added my database credentials to my .env file.
Then I tried testing it out by adding this to my web.php route file:
use MongoDB\Client as Mongo;
Route::get('mongo', function(Request $request) {
$collection = (new Mongo)->mydatabase->mycollection;
return $collection->find()->toArray();
});
This didn't work as when I visited /mongo I got this error:
Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR)
Class 'MongoDB\Driver\Manager' not found
I'm a little bit confused to how I get this to work, do I need to install it on to homestead and if so how do I do this?
Thanks
Please or to participate in this conversation.