How to generate custom error page in Laravel
Laravel makes it easy to display custom error pages for various HTTP status codes.
--
For example, if you wish to customize the error page for 404 HTTP status codes, create a resources/views/errors/404.blade.php
view template. This view will be rendered on all 404 errors generated by your application. The views within this directory should be named to match the HTTP status code they correspond to. The Symfony\Component\HttpKernel\Exception\HttpException
instance raised by the abort
function will be passed to the view as an $exception
variable:
<h2>{{ $exception->getMessage() }}</h2>
You can also publish the error pages with Artisan command. Once the templates have been published, you can start to customize it.
php artisan vendor:publish --tag=laravel-errors
example 404 page:
output:
The above is basic output, if you would like customize it you may need to edit the @extends errors layout.
If you would like to know more about Laravel, please feel free to subscribe my channel. ^^
Read More Laravel Stories: