yii2 RESTful 接口 api -2 : 自定义函数
yii2 的 restful 接口的默认 是帮写了很多的方法
下面我们需要书写自己的接口方法,譬如搜索方法。
1.更改配置:
- "urlManager" =>[
- "class" => "yiiwebUrlManager",
- "enablePrettyUrl" => true,
- "enableStrictParsing" => true,
- "showScriptName" => false,
- "rules" => [
- "" => "cms/index",
- ["class" => "yii estUrlRule","controller" =>"customer/api",
- "pluralize" => false,
- ],
- # 定义方法: public function actionSearch($name); <name> 就是search方法传入的参数
- "POST customer/api/search/<name>" => "customer/api/search",
- //"POST customer" => "customer/index/create",
- ],
- ],
声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。
copyright © 2008-2019 亿联网络 版权所有 备案号:粤ICP备14031511号-2
