dtll2016 2016-05-10 06:13
浏览 154
已采纳

PSR7请求:在Slim3中获取类似$ _REQUEST的请求数据

I am refactoring my application using PSR-7 Requests using Slim3 as Router. On some of my entry points I have incoming GET and POST HTTP-Requests from external applications. Both GET and POST use the same parameter names. In the old code, a simple $_REQUEST solved the issue, but I do not want to use the superglobals any longer.

For getting the parameters of the GET-Request, I use the following code:

$parameters = $request->getQueryParams();

For the POST-Request, I use:

$parameters = $request->getParsedBody();

Is there a PSR-7 function for solving the issue, or do I have to use array_merge() each time?

  • 写回答

2条回答 默认 最新

  • dqouryz3595 2016-05-10 08:17
    关注

    Slim's request object has getParam() and getParams() which does what you want. These are not part of PSR-7 though.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部