How to register a custom 404 in Laravel 5 Upgraded to Laravel 5 just recently to build a couple of websites for clients, and everything I know about registering a custom 404 page has completely flat lined. Has anybody figured this out yet?
Just add it in app/Http/Kernel.php :
public function handle($request)
{
try
{
return parent::handle($request);
}
catch(\Symfony\Component\HttpKernel\Exception\NotFoundHttpException $e)
{
return response()->view('my.missing', [], 404);
}
catch (Exception $e)
{
$this->reportException($e);
return $this->renderException($request, $e);
}
}
You can also add the report of the exception if you want to get it in log.
This info is now obsolete because you just have to create a resources/views/errors/404.blade.php .
Do you mean my reply? That's interesting, so just add in a 404.blade.php in views/errors and it will handle it automatically you mean?
Yea Laravel will handle it for you ;) And out of my head you will have access to $code, $message, $headers
Hmm...Not sure how to display the optional message inside a custom error-blade-template...
{{ $message }}
will result into a 'undefined variable' error.
Please sign in or create an account to participate in this conversation.