15 Star 86 Fork 26

deepziyu / yii2-fast-api

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
api.config.php 1.49 KB
一键复制 编辑 原始数据 按行查看 历史
deepziyu 提交于 2017-01-18 14:02 . add Api Document View
<?php
$config = [
'bootstrap' => [
[
'class' => 'yii\filters\ContentNegotiator',
'formats' => [
'application/json' => 'json',
'application/xml' => 'xml',
],
'languages' => [
'zh-CN',
'en',
],
]
],
'modules'=>[
'route'=>'deepziyu\yii\rest\module\RouteModule',
],
'components' => [
'errorHandler' => [
'class'=>'deepziyu\yii\rest\ErrorHandler'
],
'urlManager' => [
'enablePrettyUrl' => true,
'enableStrictParsing' => true,
'showScriptName' => false,
'rules' => [
//模块化的路径
"GET,POST,PUT,DELETE <module>/<controller:[\w-]+>/<action:[\w-]+>" => "<module>/<controller>/<action>",
//基本路径
"GET,POST,PUT,DELETE <controller:[\w-]+>/<action:[\w-]+>" => "<controller>/<action>",
],
],
'request' => [
'class' => '\yii\web\Request',
'enableCookieValidation' => false,
'parsers' => [
'application/json' => 'yii\web\JsonParser',
'text/json' => 'yii\web\JsonParser',
],
],
'response' => [
//返回异常统一处理
'on beforeSend' => function ($event) {
//$event->sender->format = 'json';
},
],
],
];
return $config;
PHP
1
https://gitee.com/deepziyu/yii2-fast-api.git
git@gitee.com:deepziyu/yii2-fast-api.git
deepziyu
yii2-fast-api
yii2-fast-api
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891