jdavidbakr / laravel-sns-error-notification
Sends a notification via SNS when there is an exception
Installs: 20 442
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: ~5.5|~7.0
- aws/aws-sdk-php-laravel: ~3.0
- illuminate/support: ~5.1
Requires (Dev)
- orchestra/testbench: ~3.0
- phpunit/phpunit: ~4.0||~5.0
- scrutinizer/ocular: ~1.1
- squizlabs/php_codesniffer: ~2.3
This package is auto-updated.
Last update: 2024-10-29 01:51:42 UTC
README
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.