main.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. ],
  17. 'controllerNamespace' => 'api\controllers',
  18. 'components' => [
  19. 'user' => [
  20. 'identityClass' => 'common\models\User',
  21. 'enableAutoLogin' => false, // API change to false
  22. 'enableSession' => false, // API ++
  23. 'loginUrl' => null // 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. 'request' => [
  35. 'class' => '\yii\web\Request',
  36. 'enableCookieValidation' => false,
  37. 'parsers' => [
  38. 'application/json' => 'yii\web\JsonParser',
  39. ],
  40. 'cookieValidationKey' => 'O1d232trde1xww-M97_7QvwPo-5QGdkLMp#@#@',
  41. ],
  42. 'errorHandler' => [
  43. 'errorAction' => 'site/error',
  44. ],
  45. 'urlManager' => [
  46. 'class' => 'yii\web\UrlManager',
  47. 'enablePrettyUrl' => true,
  48. 'enableStrictParsing' => true,
  49. 'showScriptName' => false,
  50. 'rules' => [
  51. '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
  52. '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
  53. '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
  54. // '' => 'site/index',
  55. // ['class' => 'yii\rest\UrlRule', 'controller' => 'customer/api',
  56. // 'pluralize' => false,
  57. // ],
  58. // # 定义方法: public function actionSearch($id); <id> 就是search方法传入的参数
  59. // # http://10.10.10.252:599/v1/wishorder/2015-08-11+12:12:12/2015-09-11+12:12:12?access-token=pBJi3hyFsLsTuvUM9paFpWjYRatn3qwS
  60. // # 分页:http://10.10.10.252:599/v1/wishorder/2015-08-11+12:12:12/2015-09-11+12:12:12?page=2&access-token=pBJi3hyFsLsTuvUM9paFpWjYRatn3qwS
  61. // 'GET v1/wishorder/<begin_datetime>/<end_datetime>' => 'v1/wishorder/viewbydate',
  62. // 'GET v1/ebayorder/<begin_datetime>/<end_datetime>' => 'v1/ebayorder/viewbydate',
  63. ]
  64. ],
  65. 'db' => require __DIR__ . '/../../common/config/db.php'
  66. ],
  67. 'params' => $params,
  68. ];