---
title: "Registering checks — Alerts for Laravel | Roundly"
description: "Register check classes or configured instances with the Health facade or config, and inspect the registry by key."
url: https://roundly-consulting.com/open-source/docs/alerts-for-laravel/registering-checks
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[Alerts for Laravel](https://roundly-consulting.com/open-source/docs/alerts-for-laravel.md)

# Registering checks

Register the checks your application supports, typically in a service provider’s boot():

```php
use RoundlyConsulting\Alerts\Facades\Health;

Health::check(DiskUsageCheck::class);

// Or register several at once:
Health::checks([
    DiskUsageCheck::class,
    MemoryUsageCheck::class,
]);

// The HealthManager behind the facade is also injectable (see DI and actions):
app(\RoundlyConsulting\Alerts\HealthManager::class)->checks([DiskUsageCheck::class]);
```

Or list class names in the config — they are registered when the package boots:

```php
// config/alerts.php
'checks' => [
    RoundlyConsulting\Alerts\Checks\DatabaseCheck::class,
    App\Health\DiskUsageCheck::class,
],
```

## Register in every process

The registry lives in memory. The web app, the scheduler and every queue worker need the same checks registered, so do it in a service provider or the config. When a queued job runs a row whose key is not registered in that process, it throws InvalidHealthCheck::notRegistered().

## One instance per key

Checks are stored by key(). Each check registers under a key derived from its class (database\_check, http\_ping\_check, …), and registering a second instance under the same key replaces the first. To watch several targets with one class — built-in checks included — give each instance its own key with as(). The name follows the key:

```php
use RoundlyConsulting\Alerts\Checks\DatabaseCheck;
use RoundlyConsulting\Alerts\Facades\Health;

Health::check(DatabaseCheck::make('mysql')->as('mysql_database'));   // name "Mysql Database"
Health::check(DatabaseCheck::make('pgsql')->as('pgsql_database'));

Health::for($team)->monitor('mysql_database')->everyMinute()->save();
Health::for($team)->run('pgsql_database');
```

Schedule and run such an instance by its key. Running a class registered under several keys by its class name throws InvalidHealthCheck::ambiguous(). A subclass that overrides key() keeps control of its key.

## Inspecting the registry

```php
use RoundlyConsulting\Alerts\Facades\Health;

Health::all(); // Collection<string, Check> keyed by check key

$check = Health::find('disk_usage_check');

$check->name();        // "Disk Usage Check"
$check->key();         // "disk_usage_check"
$check->description(); // "Perform Disk Usage Check and trigger notification when necessary."
$check->frequencies(); // ['* * * * *' => 'Every Minute', ...]
$check->tags();        // [] unless the class overrides tags()
```

- name() — Str::headline of the class name, or of the key given to as(); key() — the class name in snake\_case, or that key. Override either in your check.
- description() — a translatable default sentence built from the name.
- frequencies() — a cron ⇒ label map for select inputs: every minute, 5 and 10 minutes, hour, day, week, month and year. Labels pass through \_\_(), so you can translate them.
- Health::check() accepts a class name or an instance; anything that does not extend Check throws InvalidHealthCheck::doesntExtendBaseCheck().
- Health::check() and Health::checks() return the manager, so registrations chain.

## Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

[More ways to support, including crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/alerts-for-laravel.md)
