I am trying to figure out how I can send errors to my email in Laravel 5. I haven\'t had much luck finding any good resources.
There used to be good packages like: http
EDIT: I found a 3rd party log system built for Laravel
www.understand.io
I played around with this and went through the Laravel core files and came up with something similar to what you see on an error page.
You just need to create a view file that echos out $content for the email
public function report(\Exception $e)
{
if ($e instanceof \Exception) {
$debugSetting = Config::get('app.debug');
Config::set('app.debug', true);
if (ExceptionHandler::isHttpException($e)) {
$content = ExceptionHandler::toIlluminateResponse(ExceptionHandler::renderHttpException($e), $e);
} else {
$content = ExceptionHandler::toIlluminateResponse(ExceptionHandler::convertExceptionToResponse($e), $e);
}
Config::set('app.debug', $debugSetting);
$data['content'] = (!isset($content->original)) ? $e->getMessage() : $content->original;
Mail::queue('errors.emails.error', $data, function ($m) {
$m->to('email@email.com', 'Server Message')->subject('Error');
});
}
return parent::report($e);
}