You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
3.8 KiB

  1. <?php
  2. $params = array_merge(
  3. require __DIR__ . '/../../common/config/params.php', require __DIR__ . '/../../common/config/params-local.php', require __DIR__ . '/params.php', require __DIR__ . '/params-local.php'
  4. );
  5. return [
  6. 'id' => 'api',
  7. 'basePath' => dirname(__DIR__),
  8. 'controllerNamespace' => 'api\controllers',
  9. 'bootstrap' => ['log'],
  10. 'modules' => [],
  11. 'components' => [
  12. 'request' => [
  13. 'parsers' => [
  14. 'application/json' => 'yii\web\JsonParser',
  15. ],
  16. 'csrfParam' => '_csrf-api',
  17. ],
  18. 'session' => [
  19. // this is the name of the session cookie used for login on the app
  20. 'name' => 'api',
  21. ],
  22. 'log' => [
  23. 'traceLevel' => YII_DEBUG ? 3 : 0,
  24. 'targets' => [
  25. [
  26. 'class' => 'yii\log\FileTarget',
  27. 'levels' => ['error', 'warning'],
  28. ],
  29. [
  30. 'class' => 'yii\log\FileTarget',
  31. 'levels' => ['error', 'warning'],
  32. 'categories' => ['notify'],
  33. 'logFile' => '@app/runtime/logs/notify.log',
  34. 'logVars' => [],
  35. 'exportInterval' => 1,
  36. 'prefix' => function ($message) {
  37. }
  38. ],
  39. ],
  40. ],
  41. 'user' => [
  42. 'identityClass' => 'common\models\User',
  43. 'enableAutoLogin' => true,
  44. 'identityCookie' => ['name' => '_identity-api', 'httpOnly' => true],
  45. ],
  46. 'errorHandler' => [
  47. 'errorAction' => 'site/error',
  48. ],
  49. 'urlManager' => [
  50. 'enablePrettyUrl' => true,
  51. 'enableStrictParsing' => true,
  52. 'showScriptName' => false,
  53. 'rules' => [
  54. ['class' => 'yii\rest\UrlRule', 'controller' => 'goods', 'pluralize' => false],
  55. ['class' => 'yii\rest\UrlRule', 'controller' => 'address', 'pluralize' => false],
  56. ['class' => 'yii\rest\UrlRule', 'controller' => 'taking-site'],
  57. ['class' => 'yii\rest\UrlRule', 'controller' => 'cart'],
  58. ['class' => 'yii\rest\UrlRule', 'controller' => 'comment',
  59. 'extraPatterns' => [
  60. 'DELETE ' => 'delete'
  61. ]],
  62. ['class' => 'yii\rest\UrlRule', 'controller' => 'order'],
  63. ['class' => 'yii\rest\UrlRule', 'controller' => 'collection',
  64. 'extraPatterns' => [
  65. 'DELETE ' => 'delete'
  66. ]
  67. ],
  68. ['class' => 'yii\rest\UrlRule',
  69. 'controller' => 'user',
  70. 'pluralize' => false,
  71. 'extraPatterns' => [
  72. 'GET token' => 'token'
  73. ]
  74. ],
  75. [
  76. 'class' => 'yii\rest\UrlRule',
  77. 'controller' => 'admin',
  78. 'extraPatterns' => [
  79. 'GET menu' => 'menu',
  80. 'GET create' => 'create'
  81. ]
  82. ],
  83. [
  84. 'class' => 'yii\rest\UrlRule',
  85. 'controller' => 'site',
  86. 'extraPatterns' => [
  87. 'GET index' => 'index',
  88. ]
  89. ],
  90. [
  91. 'class' => 'yii\rest\UrlRule',
  92. 'controller' => 'wx-payment',
  93. 'pluralize' => false,
  94. 'extraPatterns' => [
  95. 'GET web' => 'web',
  96. 'POST notify' => 'notify',
  97. ]
  98. ],
  99. ],
  100. ],
  101. ],
  102. 'params' => $params,
  103. ];