Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel NotFoundHttpException Handling

Tags:

php

laravel-5

I am Unable to handle NotFoundHttpException in Laravel

I have already tried to handle it through render() in Handler.php


// Handler.php 
// render()
==============

public function render($request, Exception $e)
    {
        if($e instanceof NotFoundHttpException){
            return response('Not Found');
        }
        return parent::render($request,$e);
   }

It should return the response 'Not Found'. But it is returning

Class 'Symfony\Component\HttpKernel\Exception\NotFoundHttpException' not found

Which means that NotFoundHttpException class cannot be found in vendor folder, I tried to look for the class in the path specified but I could not find it.


1 Answers

use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
like image 150
Chester Avatar answered Mar 19 '26 20:03

Chester