Matheus Simon
Matheus Simon

Reputation: 696

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.

Upvotes: 3

Views: 8180

Answers (1)

Diego Vidal
Diego Vidal

Reputation: 1057

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.

Upvotes: 10

Related Questions