Online Snippets Library

Custom Error Pages in Laravel

Here we create custom error pages in Laravel.We will use following step to create custom error page.

Step 1

Go to app/config/app.php and turn the debug option to false.

'debug' => false,
Step 2

Go to app/start/global.php add search below code

App::error(function(Exception $exception, $code)

Replace above code with below code.

App::error(function(Exception $exception, $code)
    switch ($code)
        case 403:
            return Response::view('error.403', array(), 403);
        case 404:
            return Response::view('error.404', array(), 404);
        case 500:
            return Response::view('error.500', array(), 500);
            return Response::view('error.default', array(), $code);

Step 3

Create error Folder inside app/views And create following pages with your custom design.

403.blade.php 404.blade.php 500.blade.php default.blade.php