Search by

illuma-law / healthcheck-mercure

miguelenes

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!

illuma-law

Statistics

Installs: 63

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 1

v0.1.5 2026-10-23 13:57 UTC

README

Tests Latest Version License

Mercure connection health check illustration

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 mercure broadcasting 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: when true, 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.