main.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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-backend',
  10. 'basePath' => dirname(__DIR__),
  11. 'controllerNamespace' => 'backend\controllers',
  12. 'bootstrap' => ['log'],
  13. 'modules' => [],
  14. 'components' => [
  15. 'request' => [
  16. 'csrfParam' => '_csrf-backend',
  17. ],
  18. 'user' => [
  19. 'identityClass' => 'common\models\User',
  20. 'enableAutoLogin' => true,
  21. 'identityCookie' => ['name' => '_identity-backend', 'httpOnly' => true],
  22. ],
  23. 'session' => [
  24. // this is the name of the session cookie used for login on the backend
  25. 'name' => 'advanced-backend',
  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. 'class' => 'components\ErrorHandler',
  38. 'errorAction' => '/error/error',
  39. ],
  40. 'db' => require __DIR__ . '/../../common/config/db.php',
  41. 'urlManager' => [
  42. 'enablePrettyUrl' => true, //美化url==ture
  43. 'enableStrictParsing' => false, //不启用严格解析
  44. 'showScriptName' => false, //隐藏index.php
  45. 'rules' => [
  46. '<module:\w+>/<controller:\w+>/<id:\d+>' => '<module>/<controller>/view',
  47. '<controller:\w+>/<id:\d+>' => '<controller>/view',
  48. ],
  49. ]
  50. ],
  51. 'params' => $params,
  52. ];