lig*_*ght 6 php parameters routes laravel
使用Laravel 5,我无法设置获取路由参数.
我的路线设置如下:
Route::get('test', 'TestController@test');
Run Code Online (Sandbox Code Playgroud)
我的TestController看起来像这样:
public function test(Request $request)
{
var_dump($request->input('foo'));
}
Run Code Online (Sandbox Code Playgroud)
当我使用参数浏览到该路线时
/test?foo=bar
Run Code Online (Sandbox Code Playgroud)
结果是NULL.
谁能告诉我我做错了什么?
Input :: get('foo')语法也不起作用(在L5的文档中甚至没有提到).
更新:
我正在使用Apache作为网络服务器.
我也试过了
$request->get('foo')
Run Code Online (Sandbox Code Playgroud)
和这样的路线
Route::get('test/{foo?}', 'TestController@test');
Run Code Online (Sandbox Code Playgroud)
使用相同的URL并仍然为null.
更新2:
L5的文档给出了这样的路由示例:
/test/bar
Run Code Online (Sandbox Code Playgroud)
代替
/test?foo=bar
Run Code Online (Sandbox Code Playgroud)
在L4中,可以浏览到具有GET的路由
/test?foo=bar&id=2&user=admin
Run Code Online (Sandbox Code Playgroud)
或更改订单
/test?id=2&user=admin&foo=bar
Run Code Online (Sandbox Code Playgroud)
有一条相同的路线
Route::get('test', 'TestController@test');
Run Code Online (Sandbox Code Playgroud)
而你所要做的就是得到它
Input::get('user')
Run Code Online (Sandbox Code Playgroud)
但是使用L5时,如果必须在路径中使用斜杠,则无法更改参数的顺序
Route::get('test/{id}/{user}/{foo}', 'TestController@test');
Run Code Online (Sandbox Code Playgroud)
这对L5的路线来说真的是一个大降级吗?
| 归档时间: |
|
| 查看次数: |
937 次 |
| 最近记录: |