# Plugin Development: Health Checks

#### Previous Section: [Commands](Plugin+Development+Commands)

---

## What are Health Checks?

 Health checks provide a traffic light system designed to alert system administrators to issues occurring within the help desk. For more information, please refer to [System Health](System+Health).

## Registering a Health Check

A health check can be configured within the plugins `__construct` method, for example:

```

    $this->registerHealthCheck([MyHealthCheck::class]);

```

The health check class should implement the Health Check interface:

```

<?php

namespace Addons\Plugins\HelloWorld\Controllers;

use SupportPal\HealthService\Check\HealthCheck;
use SupportPal\HealthService\Model\Result;
use SupportPal\HealthService\Model\Translation;

class MyHealthCheck implements HealthCheck
{
    public function name(): Translation
    {
        return new Translation('Plugins#HelloWorld::lang.my_health_check');
    }

    public function check(): Result
    {
        if (...) {
            return Result::error($this->name(), new Translation('Plugins#HelloWorld::lang.my_health_check_error'));
        }

        return Result::healthy($this->name(), new Translation('general.ok'));
    }

    public function dependsOn(): array
    {
        return [];
    }
}

```

The `Result` class implements several statuses:

   Method name Method description     `Result::healthy(string $name, Translation $message);` The status is healthy.   `Result::warning(string $name, Translation $message, bool $healthy = true);` When `$healthy = false` the system administrator will be alerted.   `Result::error(string $name, Translation $message);` Alert the system administrator to a problem.   `Result::skip(string $name, Translation $message);` Don't show the health check in the results.  The `Translation` class can be used as follows:

   Method name Method description     `__construct(string $key, ?int $number = null)` - `$key` - The translation key, refer to [Languages](Plugin+Development+Languages)
- `$number` - For translation which implement singular and plural case, specify which to use.
 
    `setReplacements(array $replace): self` For translations which use placeholders, for example: `['path' => '/foo/bar']`  ---

#### Next Section: [Upgrading](Plugin+Development+Upgrading)