illuma-law / healthcheck-mercure
Focused mercure health check for Spatie's Laravel Health package.
Package info
github.com/eloquage/healthcheck-mercure
Language:Blade
pkg:composer/illuma-law/healthcheck-mercure
Fund package maintenance!
Requires
- php: ^8.3
- illuminate/contracts: ^12.0||^13.0
- illuminate/database: ^12.0||^13.0
- illuminate/support: ^12.0||^13.0
- spatie/laravel-health: ^1.39
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.14
- mrpunyapal/peststan: ^0.2.12
- nunomaduro/collision: ^8.8
- orchestra/testbench: ^10.1||^11.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-arch: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
- spatie/laravel-ray: ^1.35
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-10-23 13:57:32 UTC
README
A Laravel Health check that opens a short-lived subscription request to your Mercure hub and checks whether the hub accepts it.
Requirements
- PHP 8.3 or later
- Laravel 12 or 13
- Spatie Laravel Health
- A Mercure hub configured as a
mercurebroadcasting connection
Install
composer require illuma-law/healthcheck-mercure
Configure
Set the mercure connection in config/broadcasting.php:
'connections' => [ 'mercure' => [ 'url' => env('MERCURE_URL'), 'public_url' => env('MERCURE_PUBLIC_URL'), ], ],
The check prefers public_url and falls back to url. Publish package settings if you want to customize the probe:
php artisan vendor:publish --tag=healthcheck-mercure-config
Settings in config/healthcheck-mercure.php:
required: whentrue, a missing or unreachable hub fails the check; otherwise it warns. Default:false.probe_topic: topic matcher used for the subscription. Default:https://example.com/healthcheck.timeout_seconds: time allowed to open the subscription. Default:5.subscriber_token: optional bearer token for protected topics.
Environment variables are HEALTH_MERCURE_REQUIRED, HEALTH_MERCURE_PROBE_TOPIC, HEALTH_MERCURE_TIMEOUT_SECONDS, and HEALTH_MERCURE_SUBSCRIBER_TOKEN.
Use
Register the check with your Laravel Health checks:
use IllumaLaw\HealthCheckMercure\MercureCheck; use Spatie\Health\Facades\Health; Health::checks([ MercureCheck::new(), ]);
The check uses a streaming HTTP request and closes the connection after reading the response status, so an open server-sent events stream does not wait for an event or time out. It checks the subscriber request path; it does not publish an update or prove end-to-end delivery. For transport readiness, Mercure recommends its local admin endpoint at /mercure/health/ready.
Tests
composer install
composer test
composer analyse
License
MIT. See LICENSE.md.
