main.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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-api',
  10. 'basePath' => dirname(__DIR__),
  11. 'bootstrap' => ['log'],
  12. 'modules' => [
  13. 'v1' => [
  14. 'class' => 'api\modules\v1\Module'
  15. ],
  16. 'v2' => [
  17. 'class' => 'api\modules\v2\Module'
  18. ],
  19. ],
  20. 'controllerNamespace' => 'api\controllers',
  21. 'components' => [
  22. 'user' => [
  23. 'identityClass' => 'common\models\User',
  24. 'enableAutoLogin' => false, // API change to false
  25. 'enableSession' => false, // API ++
  26. 'loginUrl' => null // API ++
  27. ],
  28. 'log' => [
  29. 'traceLevel' => YII_DEBUG ? 3 : 0,
  30. 'targets' => [
  31. [
  32. 'class' => 'yii\log\FileTarget',
  33. 'levels' => ['error', 'warning'],
  34. ],
  35. ],
  36. ],
  37. 'request' => [
  38. //'class' => '\yii\web\Request',
  39. //'enableCookieValidation' => false,
  40. //'parsers' => [
  41. // 'application/json' => 'yii\web\JsonParser',
  42. //],
  43. 'baseUrl' => '/api',
  44. 'cookieValidationKey' => 'O1d232trde1xww-M97_7QvwPo-5QGdkLMp#@#@',
  45. ],
  46. /*'errorHandler' => [
  47. 'errorAction' => 'site/error',
  48. ],*/
  49. 'urlManager' => [
  50. 'enablePrettyUrl' => true,
  51. 'enableStrictParsing' => true,
  52. 'showScriptName' => false,
  53. 'rules' => [
  54. [
  55. 'class' => 'yii\rest\UrlRule',
  56. 'controller' => [
  57. 'v1/site'
  58. ]
  59. ],
  60. [
  61. 'class' => 'yii\rest\UrlRule',
  62. 'controller' => [
  63. 'v2/site'
  64. ]
  65. ]
  66. ],
  67. ],
  68. 'db' => require __DIR__ . '/../../common/config/db.php'
  69. ],
  70. 'params' => $params,
  71. ];