devexploris/myaku-health-check

Provide an endpoint for health check of application

Maintainers

Package info

github.com/DevExploris/Myaku-Health-Check

Type:symfony-bundle

pkg:composer/devexploris/myaku-health-check

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.0 2026-05-17 15:29 UTC

This package is auto-updated.

Last update: 2026-05-17 15:32:28 UTC


README

A Symfony bundle exposing a GET /health endpoint with access control and monitoring of disk space, RAM, database and cache.

Official (EN) documentation → Documentation officielle →

Requirements

  • PHP 8.2+
  • Symfony 7.4+ or 8.0+

Installation

1. Require the bundle

composer require devexploris/myaku-health-check

2. Register the bundle

// config/bundles.php
return [
    Devexploris\MyakuHealthCheck\MyakuHealthCheckBundle::class => ['all' => true],
];

3. Register the route

# config/routes.yaml
myaku_health_check:
    resource: Devexploris\MyakuHealthCheck\Controller\HealthCheckController
    type: attribute

Configuration

Create config/packages/myaku_health_check.yaml:

myaku_health_check:
    threshold:                              # optional
        space: 80                           # alert if disk usage exceeds X% (0–100)
        memory: 90                          # alert if RAM usage exceeds X% (0–100)
    space:
        path: /                             # mount point to monitor (default: /)
    security:
        token: "%env(APP_MYAKU_TOKEN)%"     # generate with: openssl rand -hex 24
        whitelist:                          # optional — if empty, all IPs are allowed
            - "127.0.0.1"
            - "172.21.0.1"

Database and cache are auto-detected via doctrine.dbal.default_connection and cache.app — no configuration needed.

Endpoint

GET /health

Response codes

Code Meaning
200 All checks are healthy
403 IP not allowed or invalid token
503 At least one check failed or exceeded its threshold

Security

Two controls are applied in order:

  1. IP whitelist — if the list is not empty, the client IP must be present, otherwise 403
  2. Token — the x-myaku-token header must match the configured token, otherwise 403

Response

{
    "space": {
        "free": "45.30 Go",
        "used": "54.70 Go",
        "total": "100.00 Go",
        "threshold": "80%",
        "threshold_targeted": false
    },
    "memory": {
        "free": "4.77 Go",
        "used": "10.04 Go",
        "total": "14.81 Go",
        "threshold": "90%",
        "threshold_targeted": false
    },
    "database": {
        "connected": true,
        "latency": "1.23ms"
    },
    "cache": {
        "connected": true,
        "latency": "0.45ms"
    }
}

threshold_targeted: true means the usage percentage exceeds the configured threshold — triggers a 503.

The threshold and threshold_targeted fields only appear if the corresponding threshold is configured.

Database error

{
    "database": {
        "connected": false,
        "error": "SQLSTATE[HY000] [2002] Connection refused"
    }
}

Cache error

{
    "cache": {
        "connected": false,
        "error": "No cache configured"
    }
}

Auto-detection

The bundle wires doctrine.dbal.default_connection and cache.app automatically when they are available in the container. No configuration needed — checks are simply skipped (returning connected: false) when the services are absent.

Compatibility

Check Linux macOS Windows
Disk space
RAM
Database
Cache

MemoryChecker reads /proc/meminfo — available on Linux only.

License

MIT