Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5 route parameters not send

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

My route is setup like this:

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

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

the result is NULL.

Can anybody tell me what I'm doing wrong?

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

Update:

I'm using Apache as webserver.

I have also tried

$request->get('foo')

and a route like this

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

with the same URL and still get null.

Update 2:

The documentation of L5 gives examples for routes like this:

/test/bar

instead of

/test?foo=bar

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

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

or changing the order

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

with one and the same route

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

and all you had to do was get it with

Input::get('user')

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');

Is this really a big downgrade for routes in L5?

like image 472
lightweight Avatar asked Apr 18 '15 20:04

lightweight


1 Answers

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

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

like image 181
lightweight Avatar answered Oct 20 '22 12:10

lightweight