Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Api restfullyii定义自定义路由_Api - Fatal编程技术网

Api restfullyii定义自定义路由

Api restfullyii定义自定义路由,api,Api,我使用yii restful扩展构建api 我想为登录创建api,它接受用户名和密码,然后返回所有用户 信息我认为正确的方法是在检查后创建自定义路由器 定义自定义路由的扩展文档部分作者说我必须创建http谓词组合(事件名称='req..\.render') [POST]api/登录/登录 要创建url,请执行以下操作 main.php array('<controller>/req.post.login', 'pattern'=>'api/<controller:\w

我使用yii restful扩展构建api

我想为登录创建api,它接受用户名和密码,然后返回所有用户

信息我认为正确的方法是在检查后创建自定义路由器

定义自定义路由的扩展文档部分作者说我必须创建http谓词组合(事件名称='req..\.render')

[POST]api/登录/登录

要创建url,请执行以下操作

main.php

 array('<controller>/req.post.login', 'pattern'=>'api/<controller:\w+>', 'verb'=>'POST'),


login Controller :
public function restEvents()
    {
        $this->onRest('req.post.login.render', function() {
            echo "sss";
            //Custom logic for this route.
            //Should output results.
            $this->emitRest('req.render.json', [
                    [
                    'type'=>'raw',
                    'data'=>['active'=>true]
                    ]
                    ])
        });
    }

  restEvents  didn't fire any help ??
main.php
数组('/req.post.login','pattern'=>'api/','verb'=>'post'),
登录控制器:
公共函数restEvents()
{
$this->onRest('req.post.login.render',function(){
回声“sss”;
//此路由的自定义逻辑。
//应该输出结果。
$this->emitRest('req.render.json'[
[
'type'=>'raw',
“数据”=>[“活动”=>true]
]
])
});
}
restEvents没有发出任何帮助??

要创建自定义路由,请将此添加到Controller,url将为


若要创建自定义路由,请将此添加到Controller,url将为

    $this->onRest('req.post.test.render',function() {


        $this->emitRest('req.render.json', [
                [
                'type'=>'raw',
                'data'=>data
                ]
                ]);
    });