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 →
- PHP 8.2+
- Symfony 7.4+ or 8.0+
composer require devexploris/myaku-health-check// config/bundles.php
return [
Devexploris\MyakuHealthCheck\MyakuHealthCheckBundle::class => ['all' => true],
];# config/routes.yaml
myaku_health_check:
resource: Devexploris\MyakuHealthCheck\Controller\HealthCheckController
type: attributeCreate 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.
GET /health
| Code | Meaning |
|---|---|
200 |
All checks are healthy |
403 |
IP not allowed or invalid token |
503 |
At least one check failed or exceeded its threshold |
Two controls are applied in order:
- IP whitelist — if the list is not empty, the client IP must be present, otherwise
403 - Token — the
x-myaku-tokenheader must match the configured token, otherwise403
{
"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
thresholdandthreshold_targetedfields only appear if the corresponding threshold is configured.
{
"database": {
"connected": false,
"error": "SQLSTATE[HY000] [2002] Connection refused"
}
}{
"cache": {
"connected": false,
"error": "No cache configured"
}
}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.
| Check | Linux | macOS | Windows |
|---|---|---|---|
| Disk space | ✅ | ✅ | ✅ |
| RAM | ✅ | ❌ | ❌ |
| Database | ✅ | ✅ | ✅ |
| Cache | ✅ | ✅ | ✅ |
MemoryCheckerreads/proc/meminfo— available on Linux only.
MIT