main.php 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. return [
  9. 'id' => 'app-frontend',
  10. 'basePath' => dirname(__DIR__),
  11. 'defaultRoute' => 'article/index',
  12. 'bootstrap' => ['log'],
  13. 'controllerNamespace' => 'frontend\controllers',
  14. 'components' => [
  15. 'user' => [
  16. 'identityClass' => common\models\User::className(),
  17. 'enableAutoLogin' => true,
  18. ],
  19. 'session' => [
  20. 'timeout' => 1440,//session过期时间,单位为秒
  21. ],
  22. 'log' => [
  23. 'traceLevel' => YII_DEBUG ? 3 : 0,
  24. 'targets' => [
  25. [
  26. 'class' => yii\log\FileTarget::className(),
  27. 'levels' => ['error', 'warning'],
  28. 'logFile' => '@runtime/logs/'.date('Y/m/d') . '.log',
  29. ],
  30. [
  31. /**
  32. 注:此配置可能造成:
  33. 1.当打开的页面包含错误时,响应缓慢。若您配置的发件箱不存在或连不上一直等待超时。
  34. 2.如果common/config/main.php mail useFileTransport为true时,并不会真发邮件,只把邮件写到runtime目录,很容易造成几十个G吃硬盘。
  35. 如您不需要发送邮件提醒建议删除此配置
  36. */
  37. 'class' => yii\log\EmailTarget::className(),
  38. 'levels' => ['error', 'warning'],
  39. 'except' => [
  40. 'yii\debug\Module::checkAccess',
  41. ],
  42. 'message' => [
  43. 'to' => ['admin@feehi.com', 'liufee@126.com'],//当触发levels配置的错误级别时,发送到此些邮箱(请改成自己的邮箱)
  44. 'subject' => '来自 Feehi CMS 前台的新日志消息',
  45. ],
  46. ],
  47. ],
  48. ],
  49. 'errorHandler' => [
  50. 'errorAction' => 'site/error',
  51. ],
  52. 'cache' => [
  53. 'class' => yii\caching\FileCache::className(),//使用文件缓存,可根据需要改成apc redis memcache等其他缓存方式
  54. 'keyPrefix' => 'frontend', // 唯一键前缀
  55. ],
  56. 'urlManager' => [
  57. 'enablePrettyUrl' => false,//true 美化路由(注:需要配合web服务器配置伪静态,详见http://doc.feehi.com/install.html), false 不美化路由
  58. 'showScriptName' => false,//隐藏index.php
  59. 'enableStrictParsing' => false,
  60. //'suffix' => '.html',//后缀,如果设置了此项,那么浏览器地址栏就必须带上.html后缀,否则会报404错误
  61. 'rules' => [
  62. //'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
  63. //'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>?id=<id>'
  64. //'detail/<id:\d+>' => 'site/detail?id=$id',
  65. //'post/22'=>'site/detail',
  66. //'<controller:detail>/<id:\d+>' => '<controller>/index',
  67. '' => 'article/index',
  68. '<page:\d+>' => 'article/index',
  69. 'login' => 'site/login',
  70. 'signup' => 'site/signup',
  71. 'view/<id:\d+>' => 'article/view',
  72. 'page/<name:\w+>' => 'page/view',
  73. 'comment' => 'article/comment',
  74. 'search' => 'search/index',
  75. 'tag/<tag:[- \w]+>' => 'search/tag',
  76. 'rss' => 'article/rss',
  77. 'list/<page:\d+>' => 'site/index',
  78. ],
  79. ],
  80. 'i18n' => [
  81. 'translations' => [
  82. 'app*' => [
  83. 'class' => yii\i18n\PhpMessageSource::className(),
  84. 'basePath' => '@backend/messages',
  85. 'sourceLanguage' => 'en-US',
  86. 'fileMap' => [
  87. 'app' => 'app.php',
  88. 'app/error' => 'error.php',
  89. ],
  90. ],
  91. 'front*' => [
  92. 'class' => yii\i18n\PhpMessageSource::className(),
  93. 'basePath' => '@frontend/messages',
  94. 'sourceLanguage' => 'en-US',
  95. 'fileMap' => [
  96. 'frontend' => 'frontend.php',
  97. 'app/error' => 'error.php',
  98. ],
  99. ],
  100. ],
  101. ],
  102. 'assetManager' => [
  103. 'linkAssets' => false,
  104. 'bundles' => [
  105. yii\widgets\ActiveFormAsset::className() => [
  106. 'js' => [
  107. ]
  108. ],
  109. yii\web\JqueryAsset::className() => [
  110. 'js' => [
  111. ],
  112. ],
  113. yii\web\YiiAsset::className() => [
  114. 'js' => [
  115. ],
  116. ],
  117. yii\validators\ValidationAsset::className() => [
  118. 'js' => [
  119. ]
  120. ],
  121. frontend\assets\AppAsset::className() => [
  122. 'sourcePath' => '@frontend/web/static',
  123. 'css' => [
  124. 'a' => 'css/style.css',
  125. 'b' => 'plugins/toastr/toastr.min.css',
  126. ],
  127. 'js' => [
  128. 'a' => 'js/index.js',
  129. 'b' => 'plugins/toastr/toastr.min.js',
  130. ],
  131. ],
  132. frontend\assets\IndexAsset::className() => [
  133. 'sourcePath' => '@frontend/web/static',
  134. 'js' => [
  135. 'a' => 'js/jquery.min.js',
  136. 'b' => 'js/responsiveslides.min.js',
  137. ]
  138. ],
  139. frontend\assets\ViewAsset::className() => [
  140. 'sourcePath' => '@frontend/web/static',
  141. 'css' => [
  142. 'a' => 'syntaxhighlighter/styles/shCoreDefault.css'
  143. ],
  144. 'js' => [
  145. 'a' => 'syntaxhighlighter/scripts/shCore.js',
  146. 'b' => 'syntaxhighlighter/scripts/shBrushJScript.js',
  147. 'c' => 'syntaxhighlighter/scripts/shBrushPython.js',
  148. 'd' => 'syntaxhighlighter/scripts/shBrushPhp.js',
  149. 'e' => 'syntaxhighlighter/scripts/shBrushJava.js',
  150. 'f' =>'syntaxhighlighter/scripts/shBrushCss.js',
  151. ]
  152. ],
  153. ]
  154. ]
  155. ],
  156. 'params' => $params,
  157. 'on beforeRequest' => [common\components\Feehi::className(), 'frontendInit'],
  158. ];