dtll2016 2016-05-10 14: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 16:17
    关注

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

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

报告相同问题?

悬赏问题

  • ¥15 怀疑手机被监控,请问怎么解决和防止
  • ¥15 Qt下使用tcp获取数据的详细操作
  • ¥15 idea右下角设置编码是灰色的
  • ¥15 全志H618ROM新增分区
  • ¥15 在grasshopper里DrawViewportWires更改预览后,禁用电池仍然显示
  • ¥15 NAO机器人的录音程序保存问题
  • ¥15 C#读写EXCEL文件,不同编译
  • ¥15 MapReduce结果输出到HBase,一直连接不上MySQL
  • ¥15 扩散模型sd.webui使用时报错“Nonetype”
  • ¥15 stm32流水灯+呼吸灯+外部中断按键