流明GET请求参数始终返回空数组

时间:2019-01-23 13:23:58

标签: php parameters request lumen

我正在Lumen内构建RESTful服务器,但是当我向查询传递参数时,$ request-> all()总是返回空数组。但是Input :: all()-显示查询参数。所以,问题是-我在做什么错了,如何通过$ request-> input()或$ request-> all()获取参数?

routes / web.php

<?php   
use Illuminate\Support\Facades\Input;
use Laravel\Lumen\Http\Request;

$router->get('/login', function (Request $request) {
    var_dump($request->all());
    var_dump(Input::all());
});

请求示例:

curl http://rest-server.loc/login?testparam=testvalue

回复:

array(0) {
}

array(1) {
  ["testparam"]=>
  string(9) "testvalue"
}

系统: Ubuntu 18.04,Apache 2.4.29,PHP 7.2.10,Lumen 5.7.7

1 个答案:

答案 0 :(得分:1)

找到了解决方案。对于请求类型,应使用 Illuminate \ Http \ Request 而不是 Laravel \ Lumen \ Http \ Request

相关问题