An exception handler for Laravel websites that will catch and forward exception via email to the website administrator.
The following packages need to be installed on the server:
git
composer
php 7.1
nginx
Run the following command in your project to add this package:
composer require gustavtrenwith/exception_handler
Then run composer update
.
Register the service providers and Facades in config/app.php
.
GustavTrenwith\ExceptionHandler\ExceptionHandlerServiceProvider::class,
'ExceptionHandler' => GustavTrenwith\ExceptionHandler\ExceptionHandlerFacade::class,
Now you can use the ExceptionHandler
facade anywhere in your application.
You need to add the following to your .env file. Then you can easily disable the exception emails by changing the variable value to true.
DISABLE_EXCEPTION_EMAILS=false
WEBMASTER_EMAIL=<YOUR_EMAIL_ADDRESS>
You need to run the following command to setup the view file.
php artisan vendor:publish --force
Now you are all set. Just paste the following line in the report()
method in the app\Exceptions\Handler.php
file.
\GustavTrenwith\ExceptionHandler\ExceptionHandler::handle($exception, env('WEBMASTER_EMAIL', ''));
For any questions or suggestions, feel free to contact me on gtrenwith@gmail.com