Custom 404 page in Lumen

后端 未结 3 1759
执笔经年
执笔经年 2021-02-04 08:13

I\'m new to Lumen and want to create an app with this framework. Now I have the problem that if some user enters a wrong url => http://www.example.com/abuot (wrong) => http://ww

3条回答
  •  闹比i
    闹比i (楼主)
    2021-02-04 08:53

    You may want to add this so that when for example blade blows up the error page hander will not throw a PHP error.

    public function render($request, Exception $exception)
     {
       if (method_exists('Exception','getStatusCode')){
    
         if($exception->getStatusCode() == 404){
           return response(view("errors.404"), 404);
         }
    
         if($exception->getStatusCode() == 500){
           return response(view("errors.500"), 404);
         }
       }
       return parent::render($request, $exception);
     }
    

提交回复
热议问题