|
69 | 69 | ]
|
70 | 70 | ]);
|
71 | 71 |
|
72 |
| -$config->callback(function() { |
73 |
| - define('YII_DEBUG', true); |
74 |
| - define('YII_ENV', 'local'); |
75 |
| -})->env(Config::ENV_LOCAL); |
| 72 | +/************ LOCAL ************/ |
76 | 73 |
|
77 |
| -// database config for |
78 |
| -$config->component('db', [ |
79 |
| - 'dsn' => 'mysql:host=localhost;dbname=DB_NAME', |
80 |
| - // 'dsn' => 'mysql:host=localhost;dbname=DB_NAME;unix_socket=/Applications/MAMP/tmp/mysql/mysql.sock', // OSX MAMP |
81 |
| - // 'dsn' => 'mysql:host=localhost;dbname=DB_NAME;unix_socket=/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock', // OSX XAMPP |
82 |
| - 'username' => '', |
83 |
| - 'password' => '', |
84 |
| -])->env(Config::ENV_LOCAL); |
| 74 | +$config->env(Config::ENV_LOCAL, function (Config $config) { |
| 75 | + $config->callback(function () { |
| 76 | + define('YII_DEBUG', true); |
| 77 | + define('YII_ENV', 'local'); |
| 78 | + }); |
85 | 79 |
|
86 |
| -/* |
87 |
| -// docker mysql config |
88 |
| -$config->component('db', [ |
89 |
| - 'dsn' => 'mysql:host=luya_db;dbname=luya_kickstarter_101', |
90 |
| - 'username' => 'luya', |
91 |
| - 'password' => 'CHANGE_ME', |
92 |
| -])->env(Config::ENV_LOCAL); |
93 |
| -*/ |
| 80 | + // docker mysql config |
| 81 | + $config->component('db', [ |
| 82 | + 'dsn' => 'mysql:host=luya_db;dbname=luya', |
| 83 | + 'username' => 'luya', |
| 84 | + 'password' => 'luya', |
| 85 | + ]); |
| 86 | + |
| 87 | + $config->component('assetManager', [ |
| 88 | + 'class' => 'luya\web\AssetManager', |
| 89 | + 'linkAssets' => true |
| 90 | + ]); |
| 91 | + |
| 92 | + // debug and gii on local env |
| 93 | + $config->module('debug', [ |
| 94 | + 'class' => 'yii\debug\Module', |
| 95 | + 'allowedIPs' => ['*'], |
| 96 | + ]); |
| 97 | + $config->module('gii', [ |
| 98 | + 'class' => 'yii\gii\Module', |
| 99 | + 'allowedIPs' => ['*'], |
| 100 | + ]); |
94 | 101 |
|
95 |
| -$config->component('db', [ |
96 |
| - 'dsn' => 'mysql:host=localhost;dbname=DB_NAME', |
97 |
| - 'username' => '', |
98 |
| - 'password' => '', |
99 |
| - 'enableSchemaCache' => true, |
100 |
| - 'schemaCacheDuration' => 0, |
101 |
| -])->env(Config::ENV_PROD); |
| 102 | + $config->bootstrap(['debug', 'gii']); |
| 103 | +}); |
102 | 104 |
|
103 |
| -$config->component('cache', [ |
104 |
| - 'class' => 'yii\caching\FileCache' |
105 |
| -])->env(Config::ENV_PROD); |
| 105 | +/************ PROD ************/ |
106 | 106 |
|
107 |
| -$config->application([ |
108 |
| - 'ensureSecureConnection' => true, // https://luya.io/guide/app-security |
109 |
| -])->env(Config::ENV_PROD); |
| 107 | +$config->env(Config::ENV_PROD, function (Config $config) { |
| 108 | + $config->component('db', [ |
| 109 | + 'dsn' => 'mysql:host=localhost;dbname=DB_NAME', |
| 110 | + 'username' => '', |
| 111 | + 'password' => '', |
| 112 | + 'enableSchemaCache' => true, |
| 113 | + 'schemaCacheDuration' => 0, |
| 114 | + ]); |
110 | 115 |
|
111 |
| -// debug and gii on local env |
112 |
| -$config->module('debug', [ |
113 |
| - 'class' => 'yii\debug\Module', |
114 |
| - 'allowedIPs' => ['*'], |
115 |
| -])->env(Config::ENV_LOCAL); |
116 |
| -$config->module('gii', [ |
117 |
| - 'class' => 'yii\gii\Module', |
118 |
| - 'allowedIPs' => ['*'], |
119 |
| -])->env(Config::ENV_LOCAL); |
120 |
| - |
121 |
| -$config->bootstrap(['debug', 'gii'])->env(Config::ENV_LOCAL); |
| 116 | + $config->component('cache', [ |
| 117 | + 'class' => 'yii\caching\FileCache' |
| 118 | + ]); |
| 119 | + |
| 120 | + $config->application([ |
| 121 | + 'ensureSecureConnection' => true, // https://luya.io/guide/app-security |
| 122 | + ]); |
| 123 | +}); |
122 | 124 |
|
123 | 125 | return $config;
|
0 commit comments