The Exception Notification package sends a mail notification when exception occurs in a Laravel application..
You can install the package via composer:
composer require javelinorg/exception-notification
You can publish the config file with:
php artisan vendor:publish --provider="Javelin\ExceptionNotification\ExceptionNotificationServiceProvider" --tag="config"
You can publish the view files with:
php artisan vendor:publish --provider="Javelin\ExceptionNotification\ExceptionNotificationServiceProvider" --tag="views"
This is the contents of the published config file:
return [
/*
|--------------------------------------------------------------------------
| Exception Notification
|--------------------------------------------------------------------------
|
| Exception notification enabled by default.
| You can disable by setting enabled to false.
*/
'enabled' => env('EXCEPTION_NOTIFICATION', true),
/*
|--------------------------------------------------------------------------
| Error email recipients
|--------------------------------------------------------------------------
|
| Here you can specify the list of recipients
|
*/
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'foo@example.com'),
'name' => env('MAIL_FROM_NAME', 'Foo'),
],
/*
|--------------------------------------------------------------------------
| Error email recipients
|--------------------------------------------------------------------------
|
| Here you can specify an array of recipients
|
*/
'toAddresses' => [
'email1@example.com',
'email2@example.com',
'email3@example.com',
],
/*
|--------------------------------------------------------------------------
| Queue customization
|--------------------------------------------------------------------------
|
| Exception notificaiton will send directly by default,
| Howerver you can enable the use of queues and customize it as per your needs.
|
*/
'queueOptions' => [
'enabled' => env('EXCEPTION_NOTIFICATION_SHOULD_QUEUE',false),
'queue' => env('EXCEPTION_NOTIFICATION_QUEUE_NAME', 'default'),
'connection' => env('QUEUE_DRIVER', 'redis'),
],
/*
|--------------------------------------------------------------------------
| A list of the exception types that should be reported.
|--------------------------------------------------------------------------
|
| For which exception class emails should be sent?
|
| You can use '*' in the array which will in turn reports every
| exception.
|
*/
'report' => [
'*',
],
/*
|--------------------------------------------------------------------------
| Crawler Bots
|--------------------------------------------------------------------------
|
| Ignore Crawler Bots
| You can use '*" in the array to ignore all kind of bots or you can specify only particular bots.
|
*/
'ignored_bots' => [
'*',
],
];
Add the line following block to the register method in App/Exceptions/Handler.php
$this->reportable(function (Throwable $th) {
if (! is_null(app()->getProvider('Javelin\ExceptionNotification\ExceptionNotificationServiceProvider'))) {
app('exceptionNotification')->reportException($th);
} // <-- The block you added
});
Add the line following block to the report method in App/Exceptions/Handler.php
if (! is_null(app()->getProvider('Javelin\ExceptionNotification\ExceptionNotificationServiceProvider'))) {
app('exceptionNotification')->reportException($exception);
}
// Once added, the mehod should look something like this:
public function report(Exception $exception) {
if (! is_null(app()->getProvider('Javelin\ExceptionNotification\ExceptionNotificationServiceProvider'))) {
app('exceptionNotification')->reportException($exception);
} // <-- The block you added
parent::report($exception);
}
Once Exception-Notification is installed and configured you can trigger a test exception by running:
php artisan exception:throw
To run tests simply run:
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.