MoncefB
MoncefB

Reputation: 145

Laravel 5.7 error 404 handling page location

I couldn't find the location of the error 404 page in Laravel 5.7 please help. here is the error page photo : https://i.sstatic.net/mYpwa.jpg

Upvotes: 13

Views: 14022

Answers (5)

Mohammad Reyhani
Mohammad Reyhani

Reputation: 1

you can use this command in terminal/cmd to show all error blades in the view directory and then you can edit them :

php artisan vendor:publish --tag=laravel-errors

also, you can show your arbitrary blade for just 404 error in route by fallback. for example :

Route::fallback(function () {
return view('myCustum404Error');
});

Upvotes: -1

Stevie B
Stevie B

Reputation: 31

If you run php artisan vendor:publish you can see a list of vendor / package files that can be published for editing.

In the list you will see laravel-errors

Type the corresponding number then you will see.

Copied Directory [/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/views] To [/resources/views/errors] Publishing complete.

You can then edit all the default error pages, including 404.blade.php 500.blade.php etc.

Upvotes: 2

GabMic
GabMic

Reputation: 1482

With every change to the framework by updating, you will override any core function. Add an errors folder in your views directory, and place blade files with the error number you wish to modify.

For example:

resources->views->errors->404.blade.php

will be shown on 404 responses. And by the way, if you love(like me) the news errors svg, you can find the in public->svg folder.

Upvotes: 3

latr.88
latr.88

Reputation: 859

You can find it here:

vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/views/404.blade.php

You shouldn't be editing this file directly though. If you want to add your custom error page just add an errors folder inside the resources/views and create your own 404.blade.php as desired. It will be used instead of Laravel's one.

Upvotes: 24

ilubis
ilubis

Reputation: 151

actually you can override it in app/Exceptions/Handler.php

and set the code look like this.

use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;


class Handler extends ExceptionHandler
{
if ($this->isHttpException($exception)) {
        if ($exception instanceof NotFoundHttpException) {
            return response()->view('error_404_path', [], 404);
            // abort(404);
        }
        return $this->renderHttpException($exception);
    }
}

Upvotes: 3

Related Questions