Skip to content

The package to send notifications for any type of server error, not just 500 errors. We'll adjust the handle a range of HTTP status codes that indicate errors, such as 500, 413, 502, etc.

License

Notifications You must be signed in to change notification settings

tariquedev/laravel-app-monitor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Laravel App Monitor

Laravel App Monitor is a package designed to monitor specific HTTP errors in your Laravel application and notify administrators via email. It helps ensure that critical errors (like 500, 502, 503, 504, 413) are promptly reported, allowing administrators to take appropriate action.

Installation

You can install the Laravel App Monitor package via Composer. Run the following command in your terminal:

composer require tarique/laravel-app-monitor

Publish Configuration

To customize settings such as email recipients or error notifications, publish the configuration file:

php artisan vendor:publish --provider="Tarique\LaravelAppMonitor\AppMonitorServiceProvider" --tag=config

This will copy the configuration file to config/appmonitor.php and app\Jobs\SendMonitorErrorNotification.php.

Environment Configuration

Set the email address where notifications should be sent in your .env file:

ADMIN_EMAIL=admin@example.com

Make sure to replace admin@example.com with the appropriate email address.

Usage

Laravel App Monitor automatically detects and handles specific HTTP errors. Here's how you can use it effectively:

Enable Error Notifications

Ensure that error notifications are enabled in the config/appmonitor.php file:

return [
    'admin_email' => env('APPMONITOR_ADMIN_EMAIL', 'admin@example.com'),
    'notify_on_down' => env('APPMONITOR_NOTIFY_ON_DOWN', true),
    'notify_on_error' => env('APPMONITOR_NOTIFY_ON_ERROR', true),
    'error_codes' => [500, 502, 503, 504, 413],
];

Customize Email Template (Optional)

If you want to customize the email template used for error notifications, you can publish the default template:

php artisan vendor:publish --provider="Tarique\LaravelAppMonitor\AppMonitorServiceProvider" --tag=views

This will copy the default email template to resources/views/vendor/appmonitor/error_email.blade.php, where you can modify it to suit your needs.

Configure Queue (Optional)

To avoid delaying frontend responses due to email sending, you can configure Laravel queues. Set the queue connection in your .env file:

QUEUE_CONNECTION=sync

If you are using QUEUE_CONNECTION as a database you should

QUEUE_CONNECTION=database

Run the migration to create the jobs table:

php artisan queue:table
php artisan migrate

Start the queue worker to process jobs asynchronously:

php artisan queue:work

Support

If you encounter any issues or have questions about using Laravel App Monitor, please open an issue on GitHub or contact the package maintainer directly.

License

Laravel App Monitor is open-source software licensed under the MIT license.

About

The package to send notifications for any type of server error, not just 500 errors. We'll adjust the handle a range of HTTP status codes that indicate errors, such as 500, 413, 502, etc.

Resources

License

Stars

Watchers

Forks

Packages

No packages published