Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$databaseName is invalid: #958

Closed
luzhuqun opened this issue Sep 19, 2016 · 2 comments
Closed

$databaseName is invalid: #958

luzhuqun opened this issue Sep 19, 2016 · 2 comments

Comments

@luzhuqun
Copy link

@luzhuqun luzhuqun commented Sep 19, 2016

in.env
DB_CONNECTION=mongodb
DB_HOST=192.168.10.8
DB_DATABASE=test
DB_USERNAME=
DB_PASSWORD=
but
InvalidArgumentException in Database.php line 66:
$databaseName is invalid:
at Connection->__construct(array('driver' => 'mongodb', 'host' => '192.168.10.8', 'port' => '27017', 'database' => null, 'username' => null, 'password' => null, 'options' => array('database' => 'test'))) in MongodbServiceProvider.php line 27
why 'database' => null?

@luzhuqun

This comment has been minimized.

Copy link
Author

@luzhuqun luzhuqun commented Sep 19, 2016

in config/database.php
'database' => env('test'),
I changed this to
'database' => 'test',
Then it's okay. Why?

@ricardofontanelli

This comment has been minimized.

Copy link

@ricardofontanelli ricardofontanelli commented Sep 19, 2016

I think the right way is:

-- config/database.php
'database' => env('DB_DATABASE', 'test'),

It means that if DB_DATABASE doesn't exist in your .env file, Laravel should use 'test'

@luzhuqun luzhuqun closed this Sep 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.