How to Create Custom Error Page in Laravel 10

 

In, Laravel provides a very simple design of all error pages, but sometimes we need to create a custom error page with our design theme. so here I will show you step by step how to create your own custom error page in the laravel 10 application.

Step 1: Install Laravel App

composer create-project laravel/laravel CustomError

Step 2: Publish Error Page

Run Below Command;

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

Step 3: Update 403 Error Page Design

view/errors/403.blade.php

<!DOCTYPE html>
    <html lang="en">
    <head>
        <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet">
        <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: 150px;
              text-shadow: 2px 4px 5px #6E6E6E;
            }
            .error-main h6{
              color: #42494F;
              font-size: 20px;
            }
            .error-main p{
              color: #9897A0;
              font-size: 15px; 
            }
        </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">403 Forbidden</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>

Run Laravel App:

php artisan serve

Now, Go to your browser, type the given URL and see the output:

http://localhost:8000/asasas