Get the App
SLTechnology News&Howtos  ›  Servers  › 

Laravel Framework 5.4 Custom error Page setup

Shulou Source: shulou.com Published: 2022-06-03 08:33:59 09月21日 Update

Encountered in the development of if this connection is the correct access address

Http://localhost/cky/ckyweb/public/admin/userlist?page=2

Then an error message will appear if I casually add a character at the end of this connection.

This is not allowed after the website is launched, so it is set up and distributed according to the definition error information page of the laravel framework.

First, you need to define the view view page, 404.blade.php page.

Then you need to find the Handler.php file in the Exceptions directory in the app directory and enter the file to modify the render method in this file.

The details are as follows:

Public function render ($request, Exception $exception) {if ($exception) {return response ()-> view ('error.'.$exception- > getStatusCode (), [], $exception- > getStatusCode ());} return parent::render ($request, $exception);}

Note:

If your custom page has parameters, you need to go through the

Return response ()-> view ('error.'.$exception- > getStatusCode (), [' parameters, parameters.'], $exception- > getStatusCode ()

Tags: Pages parameters files information directories frames addresses characters methods websites views development Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Linux MySQL Shulou Information macOS