How to Create Custom Error Page in Laravel 8?
In this tutorial, you will learn laravel 8 custom error page. i would like to show you how to create custom error page in laravel 8. This article will give you simple example of how to create 404 error page in laravel 8. In this article, we will implement a how to set 404 error page in laravel 8.
You just need to some step to done laravel 8 custom 404 page.
Normally, if you set debug false then laravel show you default error page of their predefine. but if you want to create your own custom error page then you can do it using this tutorial.
You need to create blade file like as bellow:
- 404.blade.php
- 405.blade.php
etc on errors(resources/views/errors) directory in laravel 8. you can see i created 404 blade file and check it on your project.
Almost we are using theme for front-end or backend side and we always looking for set 404, 500 or 505 error page design from there that we used for project. So it is a very simple and easy way to create custom 404 page in laravel 8 project. i added below screen shot of laravel 8 error page design.
Default 404 Page:
Now you have to just create "errors" folder in your resources directory and then after you need to create 404.blade.file inside that folder. So, basically laravel will stetted default design, but if you created 404 file into "errors" directory then it will take from there.
So, you just need to create 404 blade file and put your own code like i added then you can simply check it out.
resources/views/errors/404.blade.php
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js" ></script>
<style type="text/css">
body{
margin-top: 150px;
background-color: #C4CCD9;
}
.error-main{
background-color: #fff;
box-shadow: 0px 10px 10px -10px #5D6572;
}
.error-main h1{
font-weight: bold;
color: #444444;
font-size: 100px;
text-shadow: 2px 4px 5px #6E6E6E;
}
.error-main h6{
color: #42494F;
}
.error-main p{
color: #9897A0;
font-size: 14px;
}
</style>
</head>
<body>
<div class="container">
<div class="row text-center">
<div class="col-lg-6 offset-lg-3 col-sm-6 offset-sm-3 col-12 p-3 error-main">
<div class="row">
<div class="col-lg-8 col-12 col-sm-10 offset-lg-2 offset-sm-1">
<h1 class="m-0">404</h1>
<h6>Page not found - ItSolutionStuff.com</h6>
<p>Lorem ipsum dolor sit <span class="text-info">amet</span>, consectetur <span class="text-info">adipisicing</span> elit, sed do eiusmod.</p>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
Now you can simply run your application by following command:
php artisan serve
Now you can open following url and you will see error page as above:
http://localhost:8000/asas
Now you can simply check it out.
I hope it can help you....
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- Laravel 8 Install Vue JS Example Tutorial
- Laravel 8 Install Bootstrap Example Tutorial
- Laravel 8 Markdown | Laravel 8 Send Email using Markdown Example
- Laravel 8 Inertia JS CRUD with Jetstream & Tailwind CSS
- Laravel 8 Queue Step by Step Tutorial Example
- Laravel 8 Send Mail using Queue Example
- Laravel 8 Guzzle Http Client Request Example
- Laravel 8 Pagination Example Tutorial
- Laravel 8 Send Mail using Gmail SMTP Server
- Laravel 8 File Upload Example Tutorial