Laravel 9 Custom Error Page Example
May 09, 2022 . Admin
Hi Guys,
Today, I will describe to you how to create Custom Error Page in laravel 9. we will show an example of laravel 9 custom error page example. you will learn how to create a custom error page in laravel 9. you will learn how to create a 404 error page in laravel 9. we will help you to give an example of how to set a 404 error page in laravel 9. if you want to see an example of laravel 9 custom 404 page then you are in the right place. Let's get started with laravel 9 new error page example.
You need to create blade file like 404.blade.php, 405.blade.php, etc on the errors(resources/view.errors) directory in laravel 9. you can see I created 404 blade file and check it on your project.
Almost we are using a theme for the front-end or backend side and we always looking for set 404, 500 or 505 error page design from there that we used for the project. So it is a very simple and easy way to create a custom 404 page in laravel 9 project. I added the below screenshot of laravel 9 error page design.
Now you have to just create the "errors" folder in your resources directory and then after you need to create 404.blade.the file inside that folder. So, basically, laravel 9 will stetted the default design, but if you created a 404 file into the "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.
Download LaravelLet us begin the tutorial by installing a new laravel application. if you have already created the project, then skip following step.
composer create-project laravel/laravel example-appCreate Blade File resources/views/errors/404.blade.php
<!DOCTYPE html> <html> <head> <title>Custom Error Page</title> <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"> .error-div{ margin-top: 200px; background: #c1c1c1; padding: 70px; border-radius: 5px; } .error-div h1{ font-size: 50px; font-weight: bold; } .error-div h6{ font-family: ubuntu; font-size: 20px; } </style> </head> <body> <div class="container"> <div class="row text-center"> <div class="col-md-6 offset-md-3 error-div"> <h1>404</h1> <h6>Page not found - Mywebtuts.com</h6> </div> </div> </div> </body> </html>Run Laravel App:
All steps have been done, now you have to type the given command and hit enter to run the laravel app:
php artisan serve
Now, you have to open web browser, type the given URL and view the app output:
http://localhost:8000/okgaysOutput
I will help you...