ervinsvilumsons / laravel-alert
Laravel Alert is a package that provides an easy way to notify failed service alerts in Laravel applications.
Requires
- php: ^8.3
Requires (Dev)
- brianium/paratest: ^7.24
- laravel/pint: ^1.30
- laravel/slack-notification-channel: ^3.10
- orchestra/testbench: ^11.2
- pestphp/pest: ^5
- pestphp/pest-plugin-phpstan: ^5.2
- phpstan/phpstan: ^2.2
- rector/rector: ^2.6
Suggests
- laravel/slack-notification-channel: Required to send Slack notifications
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-09-16 17:07:20 UTC
README
Laravel Alert provides a small, configurable way to notify a group of recipients.
๐ฆ Installation
composer require ervinsvilumsons/laravel-alert
Publish the configuration:
php artisan vendor:publish --tag=alert-manager
This creates config/alert-manager.php.
๐ข Channels
Slack
composer require laravel/slack-notification-channel
The notification app must be invited to the Slack channel before alerts will be delivered. Read more about Slack notification configuration.
๐ Quick Start
use AlertManager; AlertManager::send( key: 'order_' . $order->id, title: 'Payment service unavailable', message: 'The payment provider did not respond.', context: [ 'order_id' => $order->id, 'provider' => 'acme-payments', ], level: 'critical', );
Configuration
The default configuration is:
return [ 'enabled' => env('ALERTS_ENABLED', true), 'queue' => env('ALERTS_QUEUE', 'default'), 'channels' => [ 'mail' => ['admin@example.com'], // 'slack' => ['slack channel name'], ], 'throttle' => [ 'ttl' => 3600, 'path' => storage_path('framework/cache/alert-throttle'), ], 'notification' => AlertNotification::class, ];
Custom notification
To add or replace notification channels, create a notification class with the same constructor data shape and configure it in config/alert-manager.php:
'notification' => App\Notifications\CustomAlertNotification::class,
๐งน Console Commands
alert:prune-throttle
Alert throttling stores lock files in the directory configured under alert-manager.throttle.path (default: storage/framework/cache/alert-throttle). To remove all existing throttle lock files:
php artisan alert:prune-throttle
The command is registered automatically and scheduled daily by the package's service provider. You do not need to wire anything into app/Console/Kernel.php or routes/console.php.
Sample output:
Deleted 3 file(s).
โ๏ธ License
Laravel Alert Manager is released under the MIT License.