I want to specify that if anything entered in the url address other than existing routes (in routes.php, then show 404 page.
I know about this:
App:
I would advice putting this into your app/start/global.php as that is where Laravel handles it by default (though filters.php will also work). I usually use something like this:
/*
|--------------------------------------------------------------------------
| Application Error Handler
|--------------------------------------------------------------------------
|
| Here you may handle any errors that occur in your application, including
| logging them or displaying custom views for specific errors. You may
| even register several error handlers to handle different types of
| exceptions. If nothing is returned, the default error view is
| shown, which includes a detailed stack trace during debug.
|
*/
App::error(function(Exception $exception, $code)
{
$pathInfo = Request::getPathInfo();
$message = $exception->getMessage() ?: 'Exception';
Log::error("$code - $message @ $pathInfo\r\n$exception");
if (Config::get('app.debug')) {
return;
}
switch ($code)
{
case 403:
return Response::view('errors/403', array(), 403);
case 500:
return Response::view('errors/500', array(), 500);
default:
return Response::view('errors/404', array(), $code);
}
});
Then just make an errors folder inside /views and place your error page content there. As Antonio mentioned you can pass data inside the array().
I kindly borrowed this method from https://github.com/andrewelkins/Laravel-4-Bootstrap-Starter-Site