美文网首页
关于postman 测试thinkphp的数据请求,将post自

关于postman 测试thinkphp的数据请求,将post自

作者: LewisCheng | 来源:发表于2018-11-23 18:58 被阅读0次

    本人刚接触PHP,遇到不少坑,特此记下

    。。。

    如标题问题,以本人为例,我用postman测试thinkphp接口。在postman中输入地址www.qwer.com/login.php/index/index  选择post请求,并在body里面输入参数。请求回调里面没有问题,是POST请求。

       但是,如果将上面的地址换成路由,api.qwer.com/login 。重复上述操作,那么回调过来的就是GET。

        这个问题困扰我一段时间,后来请教了在PHP摸打滚爬几年的兄弟,他说:“实际过程是 post /index.php/login 然后路由转发至 login.php/index/index 里边去了”。

        这么一说,问题也就得到了解决。

    步骤一:use think\Route;

    Route::get('/login','index/index');

    Route::post('/login','index/index');

    步骤二:

    // 入口自动绑定模块

    'auto_bind_module'      => true,//这里改为true。

    //请求地址要这样写:api.qwer/login.php/login  。入口文件带上。再去postman里面测试,OK

    相关文章

      网友评论

          本文标题:关于postman 测试thinkphp的数据请求,将post自

          本文链接:https://www.haomeiwen.com/subject/upfhqqtx.html