I'm using CakePHP 3.4
default database settings exists in config/app.php
I want to separate out or override database configuration outside app.php say in config/my_db.php
and load it in bootstrap.php
file.
This setting will now override default database setting that exists in app.php
file.
Is there some way to do this ?
Edit 2
config/my.db.php file
<?php
return [
'my_db' => [
'Datasources' => [
'default' => [
'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Mysql',
'persistent' => false,
'host' => 'localhost',
'username' => 'root',
'password' => 'my_pass',
'database' => 'testdb',
'encoding' => 'utf8',
'timezone' => 'UTC',
'flags' => [],
'cacheMetadata' => true,
'log' => false,
]
]
]
];
loading in bootstrap.php
Configure::load('my_db', 'default', false);
return [
Now you have to load it. Open file config/bootstrap.php, locate line:
Configure::load('app', 'default', false);
and append this line underneath:
Configure::load('my_db', 'default');
Try THis ::