i use different mongo db on both my production and development environment.
i am having different connection configurations because mongodb(production connection name) is on mongo atlas cluster so it connects using dsn however mongodb1 (development connection name) is installed locally so i connect it using host and port .
i want to use different db connections for different environments, so i have set DB_CONNECTION in env file different in both the cases. for my production is
DB_CONNECTION=mongodb
and for development its
DB_CONNECTION=mongodb1
in my config/database.php file
'default' => env('DB_CONNECTION', 'mysql'),
and in the connections array i have
'mongodb' => [
'driver' => 'mongodb',
'dsn' => env('MONGO_DB_DSN'),
'database' => env('MONGO_DB_DATABASE', 'uspl'),
'username' => env('MONGO_DB_USERNAME', 'uspl'),
'password' => env('MONGO_DB_PASSWORD', 'unfoldingskies'),
'options' => array(
'db' => 'uspl'
)
],
'mongodb1' => [
'driver' => 'mongodb',
'host' => env('MONGO_DB_HOST', 'localhost'),
'port' => env('MONGO_DB_PORT', 27017),
'database' => env('MONGO_DB_DATABASE'),
'options' => []
],
i am getting error on my development environment ->
Database [mongodb] not configured. in file
/var/www/html/devBackend/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php on line 152
i have tried php artisan config:clear, cache:clear, composer dump-autoload but nothing works