cms-health-project / psr15-implementation
PSR-15 implementation of the CMS HealthCheck RFC.
Requires
- php: ^8.1
- cms-health-project/serializable-reference-implementation: ^0.0.5
- psr/clock: ^1.0
- psr/event-dispatcher: ^1.0
- psr/http-client: ^1.0
- psr/http-factory: ^1.0
- psr/http-server-handler: ^1.0
Requires (Dev)
- doctrine/dbal: ^4.2
- friendsofphp/php-cs-fixer: ^3.72
- guzzlehttp/guzzle: ^7.9
- guzzlehttp/psr7: ^2.7
- laminas/laminas-diactoros: ^3.5
- nyholm/psr7: ^1.8
- php-http/discovery: ^1.20
- phpstan/phpstan: ^2.1
- phpstan/phpstan-phpunit: ^2.0
- phpunit/phpunit: ^10 || ^11 || ^12
- spatie/phpunit-snapshot-assertions: ^5.1
- symfony/clock: ^6 || ^7
- symfony/event-dispatcher: ^6.4
- symfony/framework-bundle: ^6 || ^7
- symfony/psr-http-message-bridge: ^6 || ^7
- symfony/test-pack: ^1.0
README
Introduction
To have a PSR-15 compatible request handler for the CMS health check RFC this repo is built using eqsgroup/health-check-provider as a base but using cms-health-project/serializable-reference-implementation for the actual implementation of the output schema which got slightly adjusted from the original RFC.
This was created during CloudFest Hackathon 2025.
Installation
To use this library in your project or library, require it with:
composer require "cms-health-project/psr15-implementation"
Usage
To use this in your application, you'd typically register a new route like e.g. GET /health
which can then use the RequestHandler to process the request.
To configure your health checks you have two options. You can pass instances of HealthCheckerInterface directly to the constructor of RequestHandler. It also accepts a PSR-14 Event Dispatcher which allows you to register some event listeners/subscribers that react to the CollectHealthCheckResultsEvent.
$checks = [ new CallableHealthChecker( 'callable:responseTime', fn () => true, 'your-component-id', 'your-component-type', 500, ), new DoctrineConnectionHealthChecker( $connection, ), new HttpHealthChecker( 'http:request', new Client(), new Request('GET', '/some/endpoint'), ), ]; $handler = new RequestHandler( new ResponseFactory(), new StreamFactory(), 'your-service-id', 'your-service-description', $checks, eventDispatcher: $eventDispatcher, ); $response = $handler->handle($request);
Take a look at the tests for more usage examples.