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.

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