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.

78 lines
2.7 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. 'cartLogic' => ['class' => 'api\logic\CartLogic'],
  13. 'orderLogic' => ['class' => 'api\logic\OrderLogic'],
  14. 'userLogic' => ['class' => 'api\logic\UserLogic'],
  15. 'request' => [
  16. 'parsers' => [
  17. 'application/json' => 'yii\web\JsonParser',
  18. ],
  19. 'csrfParam' => '_csrf-api',
  20. ],
  21. 'session' => [
  22. // this is the name of the session cookie used for login on the app
  23. 'name' => 'api',
  24. ],
  25. 'log' => [
  26. 'traceLevel' => YII_DEBUG ? 3 : 0,
  27. 'targets' => [
  28. [
  29. 'class' => 'yii\log\FileTarget',
  30. 'levels' => ['error', 'warning'],
  31. ],
  32. ],
  33. ],
  34. 'user' => [
  35. 'identityClass' => 'common\models\User',
  36. 'enableAutoLogin' => true,
  37. 'identityCookie' => ['name' => '_identity-api', 'httpOnly' => true],
  38. ],
  39. 'errorHandler' => [
  40. 'errorAction' => 'site/error',
  41. ],
  42. 'urlManager' => [
  43. 'enablePrettyUrl' => true,
  44. 'enableStrictParsing' => true,
  45. 'showScriptName' => false,
  46. 'rules' => [
  47. ['class' => 'yii\rest\UrlRule', 'controller' => 'goods', 'pluralize' => false],
  48. ['class' => 'yii\rest\UrlRule', 'controller' => 'cart'],
  49. ['class' => 'yii\rest\UrlRule', 'controller' => 'order'],
  50. ['class' => 'yii\rest\UrlRule',
  51. 'controller' => 'user',
  52. 'pluralize' => false,
  53. 'extraPatterns' => [
  54. 'GET token' => 'token'
  55. ]
  56. ],
  57. [
  58. 'class' => 'yii\rest\UrlRule',
  59. 'controller' => 'admin',
  60. 'extraPatterns' => [
  61. 'GET menu' => 'menu',
  62. 'GET create' => 'create'
  63. ]
  64. ],
  65. [
  66. 'class' => 'yii\rest\UrlRule',
  67. 'controller' => 'site',
  68. 'extraPatterns' => [
  69. 'GET index' => 'index',
  70. ]
  71. ],
  72. ],
  73. ],
  74. ],
  75. 'params' => $params,
  76. ];