How Can I define custom View files for each of http error responses and then ask laravel to send that view file automatically to user when I'm returning an http error response in my application?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
Basically you can define a page for every HTTP error code and put it in
resources/views/errors/
So, if you want to create a view for a 404 HTTP response you should create the view:
and Laravel will redirect automatically your users to the specific view
Additionally, you can customize the
App\Exceptions\Handler
class that is responsable for rendering errors from exceptions: therender
method is called everytime anException
rises, so you can intercept theHttpException
generated by the HTTP error and redirect wherever you want:First in
.env
file changeAPP_DEBUG=true
toAPP_DEBUG=false
Second create your custom file and rename to
404.balde.php
and copy to