Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LARAVEL 5: Change default maintenance (503) view path

When server is down, for every request MaintenanceModeException is thrown and resources/views/errors/503.blade.php is rendered. I'm trying to change it's path but can't figure out where is that exceptions treatment and 503 response.

like image 698
Matheus Simon Avatar asked Dec 06 '25 19:12

Matheus Simon


1 Answers

All http exceptions are handled by the renderHttpException() method inside \Illuminate\Foundation\Exceptions\Handler.php

/**
 * Render the given HttpException.
 *
 * @param  \Symfony\Component\HttpKernel\Exception\HttpException  $e
 * @return \Symfony\Component\HttpFoundation\Response
 */
protected function renderHttpException(HttpException $e)
{
    $status = $e->getStatusCode();

    if (view()->exists("errors.{$status}")) {
        return response()->view("errors.{$status}", ['exception' => $e], $status, $e->getHeaders());
    } else {
        return $this->convertExceptionToResponse($e);
    }
}

I assume you want to display a custom view for that 503 exception. In this case, just create your own 503.blade.php file inside resources/views/errors.

like image 118
Diego Vidal Avatar answered Dec 08 '25 21:12

Diego Vidal