jdavidbakr/laravel-sns-error-notification

Sends a notification via SNS when there is an exception

1.1.1 2017-03-21 21:06 UTC

This package is auto-updated.

Last update: 2024-11-29 01:57:53 UTC


README

Latest Version on Packagist Software License Total Downloads

This package is a simple extension of the Laravel Exception Handler that sends a notification via AWS SNS whenever there is an error, with helpful information like the URL that was called and the stack trace. The notification is cached so that it only sends one notice per unique error message every 24 hours, and only fires if the application is not in debug mode (so you aren't innundated with error messages while working on your project).

You can also enable writing to a database table, with automatic purging after a certain timeframe.

Install

Via Composer

$ composer require jdavidbakr/laravel-sns-error-notification

Add the service provider to your config/app.php file:

jdavidbakr\LaravelSNSErrorNotification\LaravelSNSErrorNotificationServiceProvider::class,

If you haven't already set up to use AWS, you will need to install the service provider:

Aws\Laravel\AwsServiceProvider::class

as well as the Facade in the 'aliases' array:

'AWS' => Aws\Laravel\AwsFacade::class,

Install the config file

php artisan vendor:publish 

This inserts a config file at config/sns-error-notification.php. You must set the SNS topic and subject in there. Also note that you will need to configure the config/aws.php file as needed to give access to the SNS topic.

Install the migrations

php artisan migrate

This installs the tables needed to store the exceptions in the database.

Usage

To use, you will need to change the app/Exceptions/Handler.php class to extend \jdavidbakr\LaravelSNSErrorNotification\ErrorNotifier instead of \Illuminate\Foundation\Exceptions\Handler. The easiest way is to remove this line:

use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;

and replace it with this:

use jdavidbakr\LaravelSNSErrorNotification\ErrorNotifier as ExceptionHandler;

Testing

$ phpunit

Contributing

Please see CONTRIBUTING and CONDUCT for details.

Security

If you discover any security related issues, please email me@jdavidbaker.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.