在我的Laravel 5.2项目中,我有一个中间件,可以愉快地存储对数据库或文件的请求和响应。我在那里serialize / json_encode$request
对象记录所有发生的事情。(Cookie,输入,文件,标题...)
我需要创建一个错误处理程序,该错误处理程序将使用整个请求对象将有关请求的所有内容包括到报告电子邮件中。但ExceptionHandler::report()
不接受Request作为参数。
Laravel 5.2提供了helper方法request()
,该方法适用于以下用例:
/**
* Report or log an exception.
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $exception
* @return void
*/
public function report(Exception $exception)
{
$request = request();
parent::report($exception);
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句