roundly-consulting / alerts-for-laravel
Schedule recurring health checks against any notifiable model, send throttled alert notifications when they fail and dispatch events when they fail, escalate or recover.
Package info
github.com/roundly-consulting/alerts-for-laravel
pkg:composer/roundly-consulting/alerts-for-laravel
Fund package maintenance!
Requires
- php: ^8.4
- illuminate/bus: ^12.0|^13.0
- illuminate/cache: ^12.0|^13.0
- illuminate/console: ^12.0|^13.0
- illuminate/contracts: ^12.0|^13.0
- illuminate/database: ^12.0|^13.0
- illuminate/http: ^12.0|^13.0
- illuminate/notifications: ^12.0|^13.0
- illuminate/queue: ^12.0|^13.0
- illuminate/support: ^12.0|^13.0
- roundly-consulting/enums-for-laravel: ^1.0
- roundly-consulting/package-toolkit-for-laravel: ^1.0
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.18
- nunomaduro/collision: ^8.5
- orchestra/testbench: ^10.0|^11.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-arch: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
- roundly-consulting/testing-for-laravel: ^1.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Alerts for Laravel
Schedule recurring health checks against any notifiable model — your own Check classes or the
built-in database, cache, queue, storage and HTTP checks. A failing check opens an alert and sends
throttled, escalating notifications; a recovered one closes it, with run history, uptime and a
status report on top.
Installation
Requires PHP 8.4 and Laravel 12 or 13.
composer require roundly-consulting/alerts-for-laravel
php artisan vendor:publish --tag="alerts-migrations"
php artisan migrate
If your owner models have UUID/ULID keys, set ALERTS_KEY_TYPE before migrating. Due checks
are dispatched as queued jobs by the auto-scheduled alerts:perform-health-checks, so keep the
scheduler and a queue worker running.
Usage
Register checks once, in a service provider's boot() — the built-ins ship a default notification:
use RoundlyConsulting\Alerts\Checks\DatabaseCheck; use RoundlyConsulting\Alerts\Checks\HttpPingCheck; use RoundlyConsulting\Alerts\Facades\Health; Health::check(DatabaseCheck::make()); Health::check(HttpPingCheck::make('https://api.example.com')->timeout(5)->slowerThan(800));
Let the owner model decide who gets notified:
use Closure; use RoundlyConsulting\Alerts\Interfaces\HasNotifiablesForAlerts; use RoundlyConsulting\Alerts\Traits\UsesHealthChecks; final class Team extends Model implements HasNotifiablesForAlerts { use UsesHealthChecks; public function forEachNotifiableForAlerts(Closure $callback): void { $this->members->each(fn (User $member) => $callback($member)); } }
Monitor a check for that owner — a failure opens an alert and notifies the team, a recovery closes it:
Health::for($team)->monitor(HttpPingCheck::class) ->everyFiveMinutes() ->failAfter(3) // open an alert only after 3 failures in a row ->save(); Health::for($team)->run(HttpPingCheck::class); // or run it now: a CheckResult Health::report()->isHealthy(); // bool, across every scheduled check
Documentation
The full documentation — configuration, every feature and its API, and testing — lives on our website: roundly-consulting.com/open-source/docs/alerts-for-laravel
Release notes are in CHANGELOG.md. To contribute, see the contributing guide.
Support our work
This package is free and open source, built and maintained by Roundly Consulting. If it saves you time, please consider supporting our open-source work — a one-time donation, a monthly pledge on Patreon or a crypto donation helps fund maintenance, new features and new packages.
License
The MIT License (MIT). Please see License File for more information.