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); });
}
there no longer is App\Providers\ErrorServiceProvider in larave 5, now what!!!!!
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
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.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community