jdavidbakr / laravel-sns-error-notification by jdavidbakr

Sends a notification via SNS when there is an exception
20,442
0
1
Package Data
Maintainer Username: jdavidbakr
Maintainer Contact: me@jdavidbaker.com (J David Baker)
Package Create Date: 2016-06-21
Package Last Update: 2017-03-21
Language: PHP
License: MIT
Last Refreshed: 2024-11-20 03:01:44
Package Statistics
Total Downloads: 20,442
Monthly Downloads: 3
Daily Downloads: 0
Total Stars: 0
Total Watchers: 1
Total Forks: 0
Total Open Issues: 0

LaravelSNSErrorNotification

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.