Support the ongoing development of Laravel.io →
posted 9 years ago
Requests
Last updated 1 year ago.
0

Into your App\Providers\ErrorServiceProvider at boot method you can register your custom 404 page.

public function boot(Handler $handler, Log $log)
{
	...

	$handler->missing(function($exception) {return \Response::view('errors.missing', array(), 404); });
}
Last updated 1 year ago.
0

there no longer is App\Providers\ErrorServiceProvider in larave 5, now what!!!!!

Last updated 1 year ago.
0

To show custom 404 page create class, for example, App\ExceptionHandler

namespace App;

use Symfony\Component\Debug\ExceptionHandler as SymfonyDisplayer;
use Symfony\Component\HttpFoundation\Response;

class ExceptionHandler extends \Illuminate\Foundation\Debug\ExceptionHandler
{
    public function render($request, \Exception $e)
    {
        if($this->config->get('app.debug'))
        {
            return (new SymfonyDisplayer($this->config->get('app.debug')))->createResponse($e);
        }
        else
        {
            return new Response(view('errors/show404'));
        }
    }
}

Then in bootstrap/app.php

$app->singleton(
	'Illuminate\Contracts\Debug\ExceptionHandler',
        // 'App\Foundation\Debug\ExceptionHandler'
	'App\ExceptionHandler'
);

And create view errors/show404.blade.php

Last updated 1 year ago.
0

Or you could just handle the errors in app\Http\Kernel.php as Laravel already does... Just edit the try/catch in the handle() method.

Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

jimserio jimserio Joined 15 Oct 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.