php - CakePHP 4 - bake won't let me use a different database connection to 'default'
one text
Solution:
same bug for me, but fixed with app_local.php:
- add
use Cake\Database\Driver\Mysql;
use Cake\Database\Connection;
before the return statement
- add className & driver to the config:
'className' => Connection::class,
'driver' => Mysql::class,
so in your case :
'interface_db' => [
'host' => 'localhost',
'className' => Connection::class,
'driver' => Mysql::class,
'username' => '***',
'password' => '***',
'database' => 'db2',
'url' => env('DATABASE_URL', null),
]
and it will work.
className & drivers are defined into app.php for de default, but not for your custom one.
Source