1
0

main.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. 'language' =>'zh-CN', //增加此行,默认使用中文
  11. 'basePath' => dirname(__DIR__),
  12. 'bootstrap' => ['log'],
  13. 'controllerNamespace' => 'frontend\controllers',
  14. 'components' => [
  15. 'request' => [
  16. 'csrfParam' => '_csrf-frontend',
  17. ],
  18. 'user' => [
  19. 'identityClass' => 'common\models\User',
  20. 'enableAutoLogin' => true,
  21. 'identityCookie' => ['name' => '_identity-frontend', 'httpOnly' => true],
  22. ],
  23. 'session' => [
  24. // this is the name of the session cookie used for login on the frontend
  25. 'name' => 'advanced-frontend',
  26. ],
  27. 'log' => [
  28. 'traceLevel' => YII_DEBUG ? 3 : 0,
  29. 'targets' => [
  30. [
  31. 'class' => 'yii\log\FileTarget',
  32. 'levels' => ['error', 'warning'],
  33. ],
  34. ],
  35. ],
  36. 'errorHandler' => [
  37. 'errorAction' => 'site/error',
  38. ],
  39. 'db' => require __DIR__ . '/../../common/config/db.php',
  40. 'urlManager' => [
  41. 'enablePrettyUrl' => true, //美化url==ture
  42. 'enableStrictParsing' => false, //不启用严格解析
  43. 'showScriptName' => false, //隐藏index.php
  44. 'rules' => [
  45. '<module:\w+>/<controller:\w+>/<id:\d+>' => '<module>/<controller>/view',
  46. '<controller:\w+>/<id:\d+>' => '<controller>/view',
  47. ],
  48. ]
  49. ],
  50. 'params' => $params,
  51. ];