main.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <?php
  2. $params = array_merge(
  3. require __DIR__ . '/../../common/config/params.php',
  4. require __DIR__ . '/../../common/config/params-local.php',
  5. require __DIR__ . '/params.php',
  6. require __DIR__ . '/params-local.php'
  7. );
  8. $emailConfig = json_decode(file_get_contents(Yii::getAlias('@backend').'/config/email.json'),true);
  9. return [
  10. 'id' => 'app-backend',
  11. 'basePath' => dirname(__DIR__),
  12. 'controllerNamespace' => 'backend\controllers',
  13. 'bootstrap' => ['log'],
  14. 'modules' => [],
  15. 'on beforeRequest' => function($event) {
  16. \yii\base\Event::on(\yii\db\BaseActiveRecord::className(), \yii\db\BaseActiveRecord::EVENT_AFTER_UPDATE, ['common\models\AdminLog', 'afterUpdate']);
  17. \yii\base\Event::on(\yii\db\BaseActiveRecord::className(), \yii\db\BaseActiveRecord::EVENT_AFTER_INSERT, ['common\models\AdminLog', 'afterInsert']);
  18. \yii\base\Event::on(\yii\db\BaseActiveRecord::className(), \yii\db\BaseActiveRecord::EVENT_AFTER_DELETE, ['common\models\AdminLog', 'afterDels']);
  19. },
  20. 'components' => [
  21. 'request' => [
  22. 'csrfParam' => 'token',
  23. ],
  24. // 'cache'=>[
  25. // 'class'=>'yii\caching\FileCache',
  26. // 'cachePath'=>'@runtime/../cachefile/',
  27. //
  28. // ],
  29. // 'user' => [
  30. // 'identityClass' => 'common\models\User',
  31. // 'enableAutoLogin' => true,
  32. // 'identityCookie' => ['name' => '_identity-backend', 'httpOnly' => true],
  33. // ],
  34. // 'pfg'=>[
  35. // 'class' => 'backend\base\ToJson',
  36. // ],
  37. 'mailer' => [ //邮箱设置
  38. 'class' => 'yii\swiftmailer\Mailer',
  39. 'useFileTransport' =>false,//这句一定有,false发送邮件,true只是生成邮件在runtime文件夹下,不发邮件
  40. 'transport' => $emailConfig,
  41. 'messageConfig'=>[
  42. 'charset'=>'UTF-8',
  43. 'from'=>[$emailConfig['username']=>'报名资料'.time()]
  44. ],
  45. ],
  46. 'session' => [
  47. // this is the name of the session cookie used for login on the backend
  48. 'name' => 'advanced-backend',
  49. ],
  50. 'log' => [
  51. 'traceLevel' => YII_DEBUG ? 3 : 0,
  52. 'targets' => [
  53. [
  54. 'class' => 'yii\log\FileTarget',
  55. 'levels' => ['error', 'warning'],
  56. ],
  57. // [
  58. // 'class' => 'yii\log\FileTarget',
  59. // 'levels' => ['error', 'warning','info'],
  60. // 'logVars'=>[],
  61. // //表示以yii\db\或者app\models\开头的分类都会写入这个文件
  62. // 'categories'=>['yii\db\*','common\models\*'],
  63. // //表示写入到文件sql.log中年月日记录日志
  64. // 'logFile'=>'@runtime/../logs/sql/sql.log'.date('Ymd'),
  65. // ]
  66. ],
  67. ],
  68. 'errorHandler' => [
  69. 'errorAction' => 'site/error',
  70. ],
  71. 'urlManager' => [
  72. 'enablePrettyUrl' => true,
  73. 'showScriptName' => false,
  74. // 'suffix'=>'',
  75. 'rules' => [
  76. '/'=>'index/index',
  77. '<controller:\w+>/<action:\w+>.html'=>'<controller>/<action>',
  78. '<controller:\w+>/<action:\w+>.php'=>'<controller>/<action>',
  79. ],
  80. ],
  81. 'assetManager' => [
  82. // 'class' => 'yii\web\AssetManager',
  83. // 'appendTimestamp' => true,
  84. // 'forceCopy' => true,
  85. 'bundles' => [
  86. 'linkAssets' => true,
  87. 'yii\web\YiiAsset' => [
  88. 'js' => [], // 去除 yii.js
  89. 'sourcePath' => null, // 防止在 frontend/web/asset 下生产文件
  90. ],
  91. 'yii\widgets\ActiveFormAsset' => [
  92. 'js' => [], // 去除 yii.activeForm.js
  93. 'sourcePath' => null, // 防止在 frontend/web/asset 下生产文件
  94. ],
  95. 'yii\validators\ValidationAsset' => [
  96. 'js' => [], // 去除 yii.validation.js
  97. 'sourcePath' => null, // 防止在 frontend/web/asset 下生产文件
  98. ],
  99. ],
  100. ],
  101. 'i18n' => [
  102. 'translations' => [
  103. 'app*' => [
  104. 'class' => 'yii\i18n\PhpMessageSource',
  105. 'basePath' => '@common/messages',
  106. // 'sourceLanguage' => 'en',
  107. 'fileMap' => [
  108. 'app' => 'app.php',
  109. // 'app/error' => 'error.php',
  110. ],
  111. ],
  112. // 'model*' => [
  113. // 'class' => 'yii\i18n\PhpMessageSource',
  114. // 'basePath' => '@common/messages',
  115. // 'fileMap' => [
  116. // 'model' => 'model.php'
  117. // ]
  118. // ]
  119. ],
  120. ],
  121. ],
  122. 'params' => $params,
  123. 'language' =>'zh-CN',
  124. ];