diff --git a/config/console.php b/config/console.php index 4eaf8ff..6b245c4 100644 --- a/config/console.php +++ b/config/console.php @@ -3,6 +3,8 @@ Yii::setAlias('@tests', dirname(__DIR__) . '/tests'); $params = require(__DIR__ . '/params.php'); +$db = require(__DIR__ . '/db.php'); + return [ 'id' => 'basic-console', 'basePath' => dirname(__DIR__), @@ -22,13 +24,7 @@ return [ ], ], ], - 'db' => [ - 'class' => 'yii\db\Connection', - 'dsn' => 'mysql:host=localhost;dbname=yii2basic', - 'username' => 'root', - 'password' => '', - 'charset' => 'utf8', - ], + 'db' => $db, 'fixture' => [ 'class' => 'yii\test\DbFixtureManager', 'basePath' => '@tests/unit/fixtures', diff --git a/config/db.php b/config/db.php new file mode 100644 index 0000000..b14e77e --- /dev/null +++ b/config/db.php @@ -0,0 +1,9 @@ + 'yii\db\Connection', + 'dsn' => 'mysql:host=localhost;dbname=yii2basic', + 'username' => 'root', + 'password' => '', + 'charset' => 'utf8', +]; diff --git a/config/web.php b/config/web.php index 67c056b..56ec9f8 100644 --- a/config/web.php +++ b/config/web.php @@ -1,6 +1,7 @@ 'basic', @@ -29,13 +30,7 @@ $config = [ ], ], ], - 'db' => [ - 'class' => 'yii\db\Connection', - 'dsn' => 'mysql:host=localhost;dbname=yii2basic', - 'username' => 'root', - 'password' => '', - 'charset' => 'utf8', - ], + 'db' => $db, ], 'params' => $params, ];