kettasoft / exception-monitor
A Laravel package to monitor exceptions and send notifications to Slack
Requires
- php: >=8.0
- laravel/framework: ^10
Requires (Dev)
- orchestra/testbench: ^8.0
- phpunit/phpunit: ^10.0
This package is auto-updated.
Last update: 2024-10-31 04:25:06 UTC
README
Laravel Exception Monitor is a package for monitoring exceptions in your Laravel application and sending notifications to Slack. It provides a simple and efficient way to stay informed about errors occurring in your application, helping you to respond quickly and maintain high application reliability.
Table of Contents
Introduction
In modern web applications, monitoring exceptions is crucial for maintaining a seamless user experience. Laravel Exception Monitor allows you to capture exceptions and send alerts directly to your Slack channel. This package streamlines error handling, enabling developers to address issues proactively.
Installation
To install the Laravel Exception Monitor package, follow these steps:
-
Install the package via Composer:
composer require kettasoft/exception-monitor
-
Publish the configuration file: After installation, you need to publish the configuration file using the following command:
php artisan vendor:publish --provider="Scaffolding\ExceptionMonitor\ExceptionMonitorServiceProvider"
-
Configure the package:
Open the published configuration file located at config/exception-monitor.php and set your Slack webhook URL:
return [
'slack_webhook_url' => env('SLACK_WEBHOOK_URL', 'https://hooks.slack.com/services/your/slack/webhook/url'),
];
Make sure to replace 'https://hooks.slack.com/services/your/slack/webhook/url'
with your actual Slack webhook URL. You can also set the environment variable SLACK_WEBHOOK_URL
in your .env
file.
Usage
To use the Laravel Exception Monitor, you simply need to ensure that your application's exception handler is set up correctly. The package integrates seamlessly with Laravel's existing exception handling.
-
Modify your exception handler:
In your app/Exceptions/Handler.php file, you can customize the report method to include the exception monitoring logic:
public function report(Throwable $exception) { parent::report($exception); // Notify Slack about the exception app(\Scaffolding\ExceptionMonitor\ExceptionMonitor::class)->report($exception); }
License
This package is open-source and available under the MIT License.