Generates Health Check pattern for PHP 8.4. Creates application-level health endpoints with component checkers (Database, Redis, RabbitMQ), status aggregation, and RFC-compliant JSON response. Includes unit tests.
From accnpx claudepluginhub dykyi-roman/awesome-claude-code --plugin accThis skill uses the workspace's default tool permissions.
references/examples.mdreferences/templates.mdCreates Health Check infrastructure for monitoring application and dependency health.
| Scenario | Example |
|---|---|
| Load balancer routing | Kubernetes liveness/readiness probes |
| Monitoring | Prometheus health scraping |
| Deployment readiness | Verify all dependencies before serving traffic |
| Dependency status | Check Database, Redis, RabbitMQ availability |
name(): string — unique identifier for the checkcheck(): HealthCheckResult — execute the health checkname, status (HealthStatus), durationMs (float), details (array)healthy(), unhealthy(), degraded()Path: src/Domain/Shared/Health/
HealthCheckInterface.php — Interface for health checksHealthStatus.php — Enum with Healthy/Degraded/Unhealthy statesHealthCheckResult.php — Immutable result value objectPath: src/Infrastructure/Health/
DatabaseHealthCheck.php — PDO connectivity checkRedisHealthCheck.php — Redis connectivity checkRabbitMqHealthCheck.php — RabbitMQ connectivity checkHealthCheckRunner.php — Runs all checks and aggregates statusPath: src/Presentation/Api/Action/
HealthCheckAction.php — PSR-15 handler returning JSON responseHealthCheckResultTest.php — Result construction and serializationHealthCheckRunnerTest.php — Aggregation and error handlingHealthCheckActionTest.php — HTTP response codes and format| Component | Path |
|---|---|
| Domain Interfaces & VOs | src/Domain/Shared/Health/ |
| Infrastructure Checkers | src/Infrastructure/Health/ |
| Presentation Action | src/Presentation/Api/Action/ |
| Unit Tests (Domain) | tests/Unit/Domain/Shared/Health/ |
| Unit Tests (Infra) | tests/Unit/Infrastructure/Health/ |
| Unit Tests (Presentation) | tests/Unit/Presentation/Api/Action/ |
| Component | Pattern | Example |
|---|---|---|
| Interface | HealthCheckInterface | HealthCheckInterface |
| Status Enum | HealthStatus | HealthStatus |
| Result VO | HealthCheckResult | HealthCheckResult |
| Checker | {Service}HealthCheck | DatabaseHealthCheck |
| Runner | HealthCheckRunner | HealthCheckRunner |
| Action | HealthCheckAction | HealthCheckAction |
| Test | {ClassName}Test | HealthCheckResultTest |
interface HealthCheckInterface
{
public function name(): string;
public function check(): HealthCheckResult;
}
enum HealthStatus: string
{
case Healthy = 'healthy';
case Degraded = 'degraded';
case Unhealthy = 'unhealthy';
public function isOperational(): bool;
public function merge(self $other): self;
}
final readonly class HealthCheckResult
{
public function __construct(
public string $name,
public HealthStatus $status,
public float $durationMs,
public array $details = []
) {}
public static function healthy(string $name, float $durationMs): self;
public static function unhealthy(string $name, float $durationMs, string $error): self;
public static function degraded(string $name, float $durationMs, string $reason): self;
public function toArray(): array;
}
// GET /health
$runner = new HealthCheckRunner($checkers, timeoutSeconds: 5);
$result = $runner->run();
// $result['status'] is HealthStatus, $result['checks'] is array<string, HealthCheckResult>
{
"status": "healthy",
"checks": {
"database": {
"name": "database",
"status": "healthy",
"duration_ms": 1.23,
"details": {}
},
"redis": {
"name": "redis",
"status": "healthy",
"duration_ms": 0.45,
"details": {}
},
"rabbitmq": {
"name": "rabbitmq",
"status": "degraded",
"duration_ms": 15.7,
"details": {
"reason": "High latency detected"
}
}
}
}
| Anti-pattern | Problem | Solution |
|---|---|---|
| Slow checks | Health endpoint times out | Set per-check timeouts |
| No timeouts | Single check blocks entire response | Use configurable timeout per runner |
| Exposing internals | Leaking credentials or internal IPs | Return only status, duration, generic details |
| Missing checks | Silent dependency failures | Register checkers for all critical dependencies |
| Synchronous only | Sequential checks increase latency | Consider parallel execution for many checks |
| No degraded state | Binary healthy/unhealthy is too rigid | Use three-state model with Degraded |
For complete PHP templates and examples, see:
references/templates.md — HealthCheckInterface, HealthStatus, HealthCheckResult, checkers, runner, action templatesreferences/examples.md — DI wiring, custom checker, and unit testsProvides UI/UX resources: 50+ styles, color palettes, font pairings, guidelines, charts for web/mobile across React, Next.js, Vue, Svelte, Tailwind, React Native, Flutter. Aids planning, building, reviewing interfaces.