PHPackages                             govigilant/vigilant-healthchecks-base - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. govigilant/vigilant-healthchecks-base

ActiveLibrary

govigilant/vigilant-healthchecks-base
=====================================

Base package for integrating healthchecks

1.1.1(4mo ago)09385MITPHPPHP ^8.2CI passing

Since Nov 30Pushed 4mo agoCompare

[ Source](https://github.com/govigilant/vigilant-healthchecks-base)[ Packagist](https://packagist.org/packages/govigilant/vigilant-healthchecks-base)[ RSS](/packages/govigilant-vigilant-healthchecks-base/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (3)Versions (4)Used By (5)

Vigilant Healthchecks Base
==========================

[](#vigilant-healthchecks-base)

This package provides common functionality for implementing healthchecks for [Vigilant](https://github.com/govigilant/vigilant) in various PHP based platforms and frameworks.

Overview
--------

[](#overview)

Vigilant supports two types of healthchecks:

- **Check**: A check that returns unhealthy, warning, or healthy status
- **Metric**: A check that returns a numeric value

This package provides base classes for both types of healthchecks that can be extended to implement custom healthchecks. It also provides a way to build responses for Vigilant to consume.

Features
--------

[](#features)

### Base Classes

[](#base-classes)

#### Check

[](#check)

Extend the `Check` class to create status-based healthchecks:

```
use Vigilant\HealthChecksBase\Checks\Check;
use Vigilant\HealthChecksBase\Data\ResultData;
use Vigilant\HealthChecksBase\Enums\Status;

class DatabaseCheck extends Check
{
    protected string $type = 'database';

    public function available(): bool
    {
        return true; // Check if this healthcheck is available
    }

    public function run(): ResultData
    {
        // Perform your check logic here
        $isConnected = $this->checkDatabaseConnection();

        return ResultData::make([
            'type' => $this->type,
            'key' => $this->key(),
            'status' => $isConnected ? Status::Healthy : Status::Unhealthy,
            'message' => $isConnected ? 'Database is connected' : 'Cannot connect to database',
            'data' => ['host' => 'localhost', 'port' => 3306], // Optional additional data
        ]);
    }
}
```

#### MetricCheck

[](#metriccheck)

Extend the `MetricCheck` class to create metric-based healthchecks. The key can be used to differentiate multiple instances of the same metric type.

```
use Vigilant\HealthChecksBase\Checks\MetricCheck;
use Vigilant\HealthChecksBase\Data\MetricData;

class ResponseTimeCheck extends MetricCheck
{
    protected string $type = 'response-time';

    public function available(): bool
    {
        return true;
    }

    public function measure(): MetricData
    {
        $responseTime = $this->measureResponseTime();

        return MetricData::make([
            'type' => $this->type,
            'key' => $this->key(),
            'value' => $responseTime,
            'unit' => 'ms', // Optional unit
        ]);
    }
}
```

### Data Classes

[](#data-classes)

#### ResultData

[](#resultdata)

Used for check results with validation:

```
use Vigilant\HealthChecksBase\Data\ResultData;
use Vigilant\HealthChecksBase\Enums\Status;

$result = ResultData::make([
    'type' => 'database',
    'key' => 'mysql-primary',
    'status' => Status::Healthy,
    'message' => 'Connected',
    'data' => ['connections' => 5],
]);
```

#### MetricData

[](#metricdata)

Used for metric results with validation:

```
use Vigilant\HealthChecksBase\Data\MetricData;

$metric = MetricData::make([
    'type' => 'cpu-usage',
    'key' => 'server-1',
    'value' => 45.2,
    'unit' => 'percent',
]);
```

### Configuration Methods

[](#configuration-methods)

Checks can be configured using static methods:

```
// Simple configuration without arguments
$config = DatabaseCheck::make();

// Configuration with constructor arguments
$config = DatabaseCheck::configure('localhost', 3306);

// Add a unique key to differentiate multiple instances
$config = DatabaseCheck::configure('localhost', 3306)->key('mysql-primary');
```

### BuildResponse

[](#buildresponse)

The `BuildResponse` class builds the final response for Vigilant:

```
use Vigilant\HealthChecksBase\BuildResponse;

$builder = new BuildResponse();

$response = $builder->build(
    checks: [
        DatabaseCheck::make(),
        CacheCheck::configure('redis')->key('cache-1'),
    ],
    metricChecks: [
        ResponseTimeCheck::make(),
        MemoryUsageCheck::make(),
    ]
);
```

### Availability Checking

[](#availability-checking)

The `available()` method determines if a check should run:

```
class RedisCheck extends Check
{
    public function available(): bool
    {
        // Only run this check if Redis extension is loaded
        return extension_loaded('redis');
    }

    public function run(): ResultData
    {
        // This will only be called if available() returns true
        // ...
    }
}
```

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Vincent Boon](https://github.com/VincentBean)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance77

Regular maintenance activity

Popularity18

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~21 days

Total

3

Last Release

127d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f21e3a721fc25c880371c5d3af4925fe83e4b9d425bf50a2cbce18ee1af45931?d=identicon)[vincentbean](/maintainers/vincentbean)

---

Top Contributors

[![VincentBean](https://avatars.githubusercontent.com/u/3906942?v=4)](https://github.com/VincentBean "VincentBean (18 commits)")

---

Tags

phphealthchecksvigilant

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/govigilant-vigilant-healthchecks-base/health.svg)

```
[![Health](https://phpackages.com/badges/govigilant-vigilant-healthchecks-base/health.svg)](https://phpackages.com/packages/govigilant-vigilant-healthchecks-base)
```

###  Alternatives

[pestphp/pest-plugin-stressless

Stressless plugin for Pest

67792.6k16](/packages/pestphp-pest-plugin-stressless)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
