Friday, September 11, 2015

How to customize laravel 5.1 default error page

Customized Laravel 5.1 default error page:

customize laravel 5.1 default error page


For customized Laravel 5.1 default error page, we have to modify following file.

app/Exceptions/Handler.php

customize laravel 5.1 default error page


 By modification this file we can override this file :

convertExceptionToResponse

customize laravel 5.1 default error page
customize laravel 5.1 default error page
customize laravel 5.1 default error page


<?php namespace App\Exceptions;

use Exception;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Symfony\Component\Debug\ExceptionHandler as SymfonyDisplayer;

class Handler extends ExceptionHandler
{
    /**
     * Convert the given exception into a Response instance.
     *
     * @param \Exception $e
     *
     * @return \Symfony\Component\HttpFoundation\Response
     */
    protected function convertExceptionToResponse(Exception $e)
    {
        $debug = config('app.debug', false);

        if ($debug) {
            return (new SymfonyDisplayer($debug))->createResponse($e);
        }

        return response()->view('errors.default', ['expection' => $e], 500);
    }
}


customize laravel 5.1 default error page


Due to doing this, we can easily modify this file :

errors.default

which is exist here:

resources/view/errors

Thanks

No comments:

Post a Comment