javelinorg / exception-notification
The Exception Notification package sends a mail notification when exception occurs in a Laravel application.
This package's canonical repository appears to be gone and the package has been frozen as a result.
Installs: 3 991
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 10
Forks: 1
Open Issues: 1
Requires
- php: ^7.3
- illuminate/console: ^6.0|^7.0|^8.0
- illuminate/mail: ^6.0|^7.0|^8.0
- illuminate/support: ^6.0|^7.0|^8.0
- jaybizzle/crawler-detect: ^1.2
- symfony/error-handler: ^4.4|^5.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.16
- orchestra/testbench: ^4.0|^5.0|^6.0
- phpunit/phpunit: ^9.0
- psalm/plugin-laravel: ^1.4
- vimeo/psalm: ^4.1
README
The Exception Notification package sends a mail notification when exception occurs in a Laravel application..
Installation
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' => [ '*', ], ];
Usage
If your using Laravel 8.x or higher
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 });
If your using between Laravel 6.x to 7.x
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
Testing
To run tests simply run:
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.