Hello,
I have installed it with Laravel 5.1 and got error during sign up Database [mongodb] not configured., but when i tried to connect to Mongo from routes
$connection = new MongoClient("mongodb://user:pass@localhost/db");
print_r($connection);
its working...
Whats my problem and how to solve it ?
Thanks
Have you put the configuration under the connections key in config/database.php
'mongodb' => array(
'driver' => 'mongodb',
'host' => 'localhost',
'port' => 27017,
'username' => 'username',
'password' => 'password',
'database' => 'database',
'options' => array(
'db' => 'admin' // sets the authentication database required by mongo 3
)
),
If so, try: dd(DB::connection('mongodb')->collection('potato')->get()); It should return []. _Note: ensure …connection( [THIS KEY] )->… matches the connection config key._
I had this problem at first, because I had a typo in my model's protected $connection attribute.
Just rebuild your config cache:
artisan config:cache
(leave the mongodb connection inside your connections array, as it is supposed to be).
Just got this issue, andresenra's answer did the trick for me.
I did but it couldn't
artisan config:cache
Most helpful comment
Just rebuild your config cache:
artisan config:cache(leave the mongodb connection inside your connections array, as it is supposed to be).