laravel5配置filp/whoops报错提示插件

  1. 1) composer.json中增加扩展
  2. "require":{
  3. "filp/whoops":"*",
  4. },
  5. 2)命令行执行 composer update
  6. 3)命令行执行 composer dump-autoload
  7. 4)监控错误信息appExceptionsHandler.php
  8. 注释原来的render方法
  9. 增加:
  10. /**
  11. * Render an exception into an HTTP response.
  12. *
  13. * @param IlluminateHttpRequest $request
  14. * @param Exception $e
  15. * @return IlluminateHttpResponse
  16. */
  17. publicfunction render($request,Exception $e)
  18. {
  19. if($this->isHttpException($e))
  20. {
  21. return $this->renderHttpException($e);
  22. }
  23. if(config('app.debug'))
  24. {
  25. return $this->renderExceptionWithWhoops($e);
  26. }
  27. return parent::render($request, $e);
  28. }
  29. /**
  30. * Render an exception using Whoops.
  31. *
  32. * @param Exception $e
  33. * @return IlluminateHttpResponse
  34. */
  35. protectedfunction renderExceptionWithWhoops(Exception $e)
  36. {
  37. $whoops =new WhoopsRun;
  38. $whoops->pushHandler(new WhoopsHandlerPrettyPageHandler());
  39. returnnew IlluminateHttpResponse(
  40. $whoops->handleException($e),
  41. $e->getStatusCode(),
  42. $e->getHeaders()
  43. );
  44. }
  45. 5)代码中测试报错:
  46. var_dump($a);die;