commit | author | age
|
90c639
|
1 |
<?php |
Z |
2 |
|
|
3 |
$local = file_exists(__DIR__ . '/local.php') ? require(__DIR__ . '/local.php') : []; |
|
4 |
$params = file_exists(__DIR__ . '/params.php') ? require(__DIR__ . '/params.php') : []; |
|
5 |
$db = file_exists(__DIR__ . '/db.php') ? require(__DIR__ . '/db.php') : [ |
|
6 |
'host' => null, |
|
7 |
'port' => null, |
|
8 |
'dbname' => null, |
|
9 |
'username' => null, |
|
10 |
'password' => null, |
|
11 |
'tablePrefix' => null, |
|
12 |
]; |
|
13 |
if (isset($local['queue'])) { |
|
14 |
$local['queue3'] = $local['queue']; |
|
15 |
$local['queue3']['channel'] = $local['queue']['channel'] . '_other'; |
|
16 |
|
|
17 |
$local['queue4'] = $local['queue']; |
|
18 |
$local['queue4']['channel'] = $local['queue']['channel'] . '_export'; |
|
19 |
} |
|
20 |
|
|
21 |
$config = [ |
|
22 |
'id' => 'zjhj_mall_v4', |
|
23 |
'basePath' => dirname(__DIR__), |
|
24 |
'language' => 'zh-CN', |
|
25 |
'timeZone' => 'Asia/Shanghai', |
|
26 |
'bootstrap' => ['log', 'queue', 'queue3', 'queue4'], |
|
27 |
'components' => [ |
|
28 |
'cache' => isset($local['cache']) ? $local['cache'] : [ |
|
29 |
'class' => 'yii\caching\FileCache', |
|
30 |
], |
|
31 |
'db' => [ |
|
32 |
'class' => 'yii\db\Connection', |
|
33 |
'dsn' => 'mysql:host=' . $db['host'] . ';port=' . $db['port'] . ';dbname=' . $db['dbname'], |
|
34 |
'username' => $db['username'], |
|
35 |
'password' => $db['password'], |
|
36 |
'tablePrefix' => $db['tablePrefix'], |
|
37 |
'charset' => 'utf8mb4', |
|
38 |
'attributes' => [ |
|
39 |
// Windows 环境下貌似无效? |
|
40 |
// PDO::ATTR_EMULATE_PREPARES => false, |
|
41 |
// PDO::ATTR_STRINGIFY_FETCHES => false, |
|
42 |
], |
|
43 |
'enableSchemaCache' => isset($local['enableSchemaCache']) ? $local['enableSchemaCache'] : false, |
|
44 |
// Duration of schema cache. |
|
45 |
'schemaCacheDuration' => isset($local['schemaCacheDuration']) ? $local['schemaCacheDuration'] : 3600, |
|
46 |
// Name of the cache component used to store schema information |
|
47 |
'schemaCache' => isset($local['schemaCache']) ? $local['schemaCache'] : 'cache', |
|
48 |
'on afterOpen' => function ($event) { |
|
49 |
Yii::$app->db->createCommand( |
|
50 |
"SET SESSION sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'" |
|
51 |
)->execute(); |
|
52 |
}, |
|
53 |
], |
|
54 |
'log' => isset($local['log']) ? $local['log'] : [ |
|
55 |
'traceLevel' => YII_DEBUG ? 3 : 0, |
|
56 |
'targets' => [ |
|
57 |
[ |
|
58 |
'class' => 'yii\log\FileTarget', |
|
59 |
'levels' => ['error', 'warning',], |
|
60 |
'logVars' => ['_GET', '_POST', '_FILES',], |
|
61 |
], |
|
62 |
], |
|
63 |
], |
|
64 |
'mailer' => [ |
|
65 |
'class' => 'yii\swiftmailer\Mailer', |
|
66 |
'viewPath' => '@app/core/mail', |
|
67 |
'useFileTransport' => false, |
|
68 |
'transport' => [ |
|
69 |
'class' => 'Swift_SmtpTransport', |
|
70 |
'host' => 'smtp.qq.com', |
|
71 |
'port' => '465', |
|
72 |
'encryption' => 'ssl', |
|
73 |
], |
|
74 |
'messageConfig' => [ |
|
75 |
'charset' => 'UTF-8', |
|
76 |
], |
|
77 |
], |
|
78 |
'plugin' => [ |
|
79 |
'class' => '\app\core\Plugin', |
|
80 |
], |
|
81 |
'mutex' => [ |
|
82 |
'class' => \yii\mutex\MysqlMutex::class, |
|
83 |
], |
|
84 |
'queue' => isset($local['queue']) ? $local['queue'] : [ |
|
85 |
'class' => \yii\queue\db\Queue::class, |
|
86 |
'tableName' => '{{%core_queue}}', |
|
87 |
], |
|
88 |
'queue3' => isset($local['queue3']) ? $local['queue3'] : [ |
|
89 |
'class' => \yii\queue\db\Queue::class, |
|
90 |
'tableName' => '{{%core_queue}}', |
|
91 |
], |
|
92 |
'queue4' => isset($local['queue4']) ? $local['queue4'] : [ |
|
93 |
'class' => \yii\queue\db\Queue::class, |
|
94 |
'tableName' => '{{%core_queue}}', |
|
95 |
], |
|
96 |
'serializer' => [ |
|
97 |
'class' => '\app\core\Serializer', |
|
98 |
], |
|
99 |
'session' => isset($local['session']) ? $local['session'] : [ |
|
100 |
'name' => 'HJ_SESSION_ID', |
|
101 |
'class' => 'yii\web\DbSession', |
|
102 |
'sessionTable' => '{{%core_session}}', |
|
103 |
], |
|
104 |
'user' => [ |
|
105 |
'class' => 'yii\web\User', |
|
106 |
'identityClass' => 'app\models\User', |
|
107 |
'enableAutoLogin' => true, |
|
108 |
], |
|
109 |
], |
|
110 |
'aliases' => [ |
|
111 |
'@bower' => '@vendor/bower-asset', |
|
112 |
], |
|
113 |
'params' => $params, |
|
114 |
'modules' => [ |
|
115 |
], |
|
116 |
]; |
|
117 |
if (!$db['username']) { |
|
118 |
unset($config['components']['session']); |
|
119 |
} |
|
120 |
if (!empty($local['redis'])) { |
|
121 |
$config['components']['redis'] = $local['redis']; |
|
122 |
} |
|
123 |
return $config; |