Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 4 handling 404 errors

I am new to Laravel and I'm trying to catch any requests that do not match existing routes. Currently I am getting a ...

Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException

I have created an App::missing() handler in the app/start/global.php as described on the documentation page but that doesn't help. I also tried creating an App::error(function(NotFoundHttpException $exception, $code) handler, but that didn't help either.

Any help would be appreciated.

like image 791
user1827863 Avatar asked Jul 15 '13 19:07

user1827863


1 Answers

You need this: In 'app/start/global.php' add:

App::missing(function($exception)
 {
     return Response::view('errorView', array(), 404);
 });

And of course in views create (in this case) errorView.blade.php
EDIT: This method handle all "404 Not Found" errors.

like image 153
Lajdák Marek Avatar answered Jan 02 '23 09:01

Lajdák Marek