Laravel 5路由参数未发送 [英] Laravel 5 route parameters not send

查看:91
本文介绍了Laravel 5路由参数未发送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Laravel 5,我无法设置获取路线参数.

With Laravel 5 I'm not able to setup get route parameters.

我的路线设置如下:

Route::get('test', 'TestController@test');

我的TestController看起来像这样:

And my TestController looks like this:

public function test(Request $request)
{
    var_dump($request->input('foo'));
}

当我使用参数浏览到该路线时

When I browse to that route with a parameter

/test?foo=bar

结果为NULL.

有人可以告诉我我在做什么错吗?

Can anybody tell me what I'm doing wrong?

Input :: get('foo')语法也不起作用(L5文档中甚至没有提及).

The Input::get('foo') syntax doesn't work either (and is not even mentioned in the documentation for L5).

更新:

我正在使用Apache作为Web服务器.

I'm using Apache as webserver.

我也尝试过

$request->get('foo')

和这样的路线

Route::get('test/{foo?}', 'TestController@test');

具有相同的网址,但仍然为空.

with the same URL and still get null.

更新2:

L5的文档提供了有关以下路线的示例:

The documentation of L5 gives examples for routes like this:

/test/bar

代替

/test?foo=bar

在L4中,可以使用GET like浏览到路由

In L4 it was possible to browse to routes with GET like

/test?foo=bar&id=2&user=admin

或更改订单

/test?id=2&user=admin&foo=bar

一条路线相同

Route::get('test', 'TestController@test');

所有您需要做的就是

Input::get('user')

但是在L5中,当您必须在类似这样的路由中使用斜杠时,将无法更改参数的顺序

But with L5 it wouldn't be possible to change the order of parameters when you have to use slashes in the routes like

Route::get('test/{id}/{user}/{foo}', 'TestController@test');

对于L5的路线,这真的是一个很大的降级吗?

Is this really a big downgrade for routes in L5?

推荐答案

问题是.htaccess文件,我使用了一个未发送参数的已编辑文件.

The problem was the .htaccess file, I used an edited one where the parameters didn't get send.

使用框架随附的默认.htaccess文件,一切正常!

With the default .htaccess file that comes with the Framework everything works!

这篇关于Laravel 5路由参数未发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆