O
O
ObehanProger2019-08-28 18:53:26
Laravel
ObehanProger, 2019-08-28 18:53:26

Which class is responsible for handling 404 non-existent route errors?

Friends, I need a certain php code to run when a 404 error occurs. Where to put it in Laravel? I believe in handler.php before parent::render(). Or do something differently? Is there any standard?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
NubasLol, 2019-08-29
@ObehanProger

class Handler extends ExceptionHandler

protected function renderHttpException(HttpExceptionInterface $e)
    {
        $status = $e->getStatusCode();

        if ($status == 404) {
           //code
        }

        return $this->convertExceptionToResponse($e);
    }

K
Kirill Sannikov, 2019-08-28
@k-sannikow

I think this is one of the solutions to this problem.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question