Error Mailer for Laravel 5.2
Laravel Error Mailer can be installed via Composer by requiring the alverated/laravel-error-mailer
package in your project's composer.json
.
{
"require": {
"alverated/laravel-error-mailer": "dev-master"
}
}
Register the service provider with the application. Open up config/app.php
and find the providers
key.
'providers' => [
// ...
Alverated\LaravelErrorMailer\ErrorMailerServiceProvider::class,
],
Publish the configurations Run this on the command line from the root of your project.
$ php artisan vendor:publish
A configuration and blade file will be publish to config/laravel-error-mailer.php
and views/vendor/mailer.blade.php
.
Update your settings in the generated configuration file.
##Usage
Open app/Exceptions/Handler.php
and import Alverated\LaravelErrorMailer\ErrorMailer
//...
use Alverated\LaravelErrorMailer\ErrorMailer;
and add these two lines of codes to public function report(Exception $e)
below parent::report($e);
public function report(Exception $e)
{
parent::report($e);
// add this code
if ($this->shouldReport($e)) {
$err = new ErrorMailer($e);
$err->sendError();
}
}
###Note Add this to your composer.json if you're using any of these drivers
{
"require": {
"guzzlehttp/guzzle": "~5.3|~6.0",
"aws/aws-sdk-php": "~3.0"
}
}