CakePHP 4.0.8
In my config/app_local.php
I have 2 different databases defined:
'Datasources' => [
'default' => [
'host' => 'localhost',
'username' => '***',
'password' => '***',
'database' => 'db1',
'url' => env('DATABASE_URL', null),
],
'interface_db' => [
'host' => 'localhost',
'username' => '***',
'password' => '***',
'database' => 'db2',
'url' => env('DATABASE_URL', null),
]
]
When I execute php bin/cake.php bake model
it will list tables in the default
database configuration, i.e. any tables in db1
.
I can't change to interface_db
and bake models for db2
. In CakePHP 3 I used the -c
flag with bake to change the connection, e.g. bin/cake.php bake model -cinterface_db
This gives an error:
2020-06-05 12:14:53 Error: [Cake\Datasource\Exception\MissingDatasourceConfigException] The datasource configuration "interface_db" was not found. in .../vendor/cakephp/cakephp/src/Datasource/ConnectionManager.php on line 203
The array key interface_db
defines the connection to db2
.
Why is this occurring? It used to work in Cake 3.