Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5 Function () not found

I'm putting together a site which has a protected section where users must be logged in to access. I've done this in Laravel 4 without too much incident. However, for the life of me I cannot figure out why I can't get it to work in Laravel 5(L5).

In L5 middleware was/were introduced. This changes the route file to:

Route::get('foo/bar', ['middleware'=>'auth','FooController@index']); Route::get('foo/bar/{id}', ['middleware'=>'auth','FooController@show']); 

The route works fine as long as the middleware is not included.

When the route is accessed with the middleware however the result is not so much fun.

Whoops, looks like something went wrong.

ReflectionException in Route.php line 150:

Function () does not exist

Any insight, help, and/or assistance is very appreciated. I've done the Google circuit and couldn't find anything relevant to my current plight. Thanks in advance.

like image 476
joseph Avatar asked Feb 13 '15 05:02

joseph


People also ask

How do I fix error 404 in Laravel?

The fix was to rename parameters. Laravel doesn't accept minus character - . Rather than that you have to use camelCase or underscore ( _ ) variable naming conventions.

What is request() in Laravel?

Introduction. Laravel's Illuminate\Http\Request class provides an object-oriented way to interact with the current HTTP request being handled by your application as well as retrieve the input, cookies, and files that were submitted with the request.

How do I fix 404 Not Found in Laravel 9?

How do I fix 404 Not Found in laravel 9? It should be enough to just run php artisan vendor:publish –tag=laravel-errors and then edit the newly created resources/views/errors/404. blade.


1 Answers

you forgot the uses key :

Route::get('foo/bar/{id}', ['middleware'=>'auth', 'uses'=>'FooController@show']); 
like image 129
manix Avatar answered Sep 18 '22 16:09

manix