PHPackages                             tiny-blocks/http-health-check - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. tiny-blocks/http-health-check

ActiveLibrary[HTTP &amp; Networking](/categories/http)

tiny-blocks/http-health-check
=============================

PSR-15 liveness and readiness request handlers with configurable health checks for HTTP services.

1.0.0(today)00MITPHPPHP ^8.5CI passing

Since Jun 26Pushed todayCompare

[ Source](https://github.com/tiny-blocks/http-health-check)[ Packagist](https://packagist.org/packages/tiny-blocks/http-health-check)[ Docs](https://github.com/tiny-blocks/http-health-check)[ RSS](/packages/tiny-blocks-http-health-check/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (13)Versions (3)Used By (0)

Http Health Check
=================

[](#http-health-check)

[![License](https://camo.githubusercontent.com/f8df3091bbe1149f398a5369b2c39e896766f9f6efba3477c63e9b4aa940ef14/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e)](https://github.com/tiny-blocks/http-health-check/blob/main/LICENSE)

- [Overview](#overview)
- [Installation](#installation)
- [How to use](#how-to-use)
    - [Liveness handler](#liveness-handler)
    - [Readiness handler](#readiness-handler)
    - [Database checks with Doctrine](#database-checks-with-doctrine)
    - [AWS SSM checks](#aws-ssm-checks)
    - [Drain marker](#drain-marker)
    - [Custom health checks](#custom-health-checks)
    - [Readiness payload](#readiness-payload)
- [License](#license)
- [Contributing](#contributing)

Overview
--------

[](#overview)

Framework-agnostic, infrastructure-agnostic readiness and liveness checking, exposed over HTTP through PSR-15 request handlers.

The library separates two concerns. The domain (`HealthCheck`, `Health`, `Status`, `Readiness`, `HealthChecks`, `HealthReport`) describes dependencies and aggregates their outcome without importing Doctrine, AWS, or PSR. It is usable outside HTTP. The HTTP adapter (`LivenessHandler`, `ReadinessHandler`, `DrainMarker`) is the deliverable you route your probes to.

Each dependency is registered as critical or optional. The aggregate readiness follows a single rule: any critical check down makes the service `UNAVAILABLE`, otherwise any optional check down makes it `DEGRADED`, otherwise it is `HEALTHY`. An empty set of checks is `HEALTHY` because nothing was registered. The readiness endpoint maps that outcome to an HTTP status.

ReadinessMeaningHTTP status`HEALTHY`Every critical check is up and no optional check is down.`200``DEGRADED`Every critical check is up, at least one optional check down.`200``UNAVAILABLE`At least one critical check is down, or the service drains.`503`Two concrete drivers ship with the library: `DoctrineHealthCheck` for databases and `SsmHealthCheck`for AWS SSM. Their third-party packages are optional. Install `doctrine/dbal` only when you use the Doctrine driver, and `aws/aws-sdk-php` only when you use the SSM driver. Every check exposes a generic `component()` category (for example "database"), never a specific host or connection name.

Installation
------------

[](#installation)

```
composer require tiny-blocks/http-health-check
```

How to use
----------

[](#how-to-use)

### Liveness handler

[](#liveness-handler)

The liveness endpoint answers `200` as long as the process can serve the request. It runs no checks and exists to tell an orchestrator whether the process should be restarted.

```
