by shigemk2

当面は技術的なことしか書かない

CakePHP2 DATABASE_CONFIG

book.cakephp.org

database.phpにこんな感じのクラスを書ける。クラスをかけると言うことは、コンストラクタも書けるので、なんかラッパーしたいときはコンストラクタに追加実装することもできる。

class DATABASE_CONFIG {
    public $default = array(
        'datasource'  => 'Database/Mysql',
        'persistent'  => false,
        'host'        => 'localhost',
        'login'       => 'cakephpuser',
        'password'    => 'c4k3roxx!',
        'database'    => 'my_cakephp_project',
        'prefix'      => ''
    );
}

と思ったら、CakePHP3からは無くなっていた。

github.com

With a PHP code based config file it will still be possible. The config file and bootstrap.php are still code in App. If developers want to get fancy and use additional logic to define their connections they can by removing the ConnectionManager::config() call in Config/bootstrap.php and inserting the logic they require there.

ここら辺がヒントになるかもしれないし、ならないかもしれない。