zoukankan      html  css  js  c++  java
  • Bringing Whoops Back to Laravel 5

    You might be missing the "prettier" Whoops error handler from Laravel 4. If so, here's how to bring it back.

    First, composer require filp/whoops:~1.0.

    Then open app/Exceptions/Handler.php, and in the render() method, add a Whoops handler in the else condition. Maybe something like this:

        /**
         * Render an exception into an HTTP response.
         *
         * @param  IlluminateHttpRequest  $request
         * @param  Exception  $e
         * @return IlluminateHttpResponse
         */
        public function render($request, Exception $e)
        {
            if ($this->isHttpException($e))
            {
                return $this->renderHttpException($e);
            }
    
    
            if (config('app.debug'))
            {
                return $this->renderExceptionWithWhoops($e);
            }
    
            return parent::render($request, $e);
        }
    
        /**
         * Render an exception using Whoops.
         * 
         * @param  Exception $e
         * @return IlluminateHttpResponse
         */
        protected function renderExceptionWithWhoops(Exception $e)
        {
            $whoops = new WhoopsRun;
            $whoops->pushHandler(new WhoopsHandlerPrettyPageHandler());
    
            return new IlluminateHttpResponse(
                $whoops->handleException($e),
                $e->getStatusCode(),
                $e->getHeaders()
            );
        }

    That's it!

    Thanks to this thread on the Laracasts forum for getting me moving in the right direction.

    参考地址:https://laracasts.com/discuss/channels/general-discussion/whoops-removed-from-laravel-5

    原文地址:https://mattstauffer.co/blog/bringing-whoops-back-to-laravel-5

  • 相关阅读:
    zz 使用svn——项目的目录布局
    eclipse中字体太小
    SVN 项目的目录结构
    tuscany requires 学习
    搜索子集生成
    HZNUACM寒假集训Day12小结 数论入门
    HZNUACM寒假集训Day10小结 树树形DP
    模板 快速幂|取余
    HZNUACM寒假集训Day7小结 背包DP
    HZNUACM寒假集训Day6小结 线性DP
  • 原文地址:https://www.cnblogs.com/kelsen/p/4331492.html
Copyright © 2011-2022 走看看