Reputation: 145
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
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
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
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
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
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