cego / service-health-checking
A package containing a generic health check endpoint designed with expansion in mind
Requires
- php: ^7.4|^8.0
- ext-json: *
- illuminate/http: ^7.0|^8.0|^9.0|^10.0|^11.0|^12.0|^13.0
- illuminate/support: ^7.0|^8.0|^9.0|^10.0|^11.0|^12.0|^13.0
Requires (Dev)
- cego/php-cs-fixer: ^2.0.0
- cego/phpstan: ^4.0.0
- orchestra/testbench: ^10.0
- phpunit/phpunit: ^11.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
- dev-main
- 2.1.0
- 2.0.0
- 1.3.0
- 1.2.0
- 1.1.1
- 1.1.0
- 1.0.0
- 0.6.0
- 0.5.5
- 0.5.4
- 0.5.3
- 0.5.2
- 0.5.1
- 0.5.0
- 0.4.1
- 0.4.0
- 0.3.1
- 0.3.0
- 0.2.6
- 0.2.5
- 0.2.4
- 0.2.3
- 0.2.2
- 0.2.1
- 0.2.0
- 0.1.1
- 0.1.0
- dev-lejo/add-route-middleware-config
- dev-thwo/minimize-default-checks
- dev-remove-ri-checks-from-defaults
- dev-lejo/laravel-12
- dev-thwo/guzzle-security-vulnerability
- dev-nbj/prepare-for-laravel-10
- dev-thwo/randomize-cache-check-key
- dev-thwo/more-informative-about-ri-thresholds
- dev-thwo/handle-exceptions
- dev-set-active-limit-1k
- dev-niza/bump-package-versions-to-laravel9
- dev-thwo/use-config-facade
- dev-thwo/merge-config
This package is auto-updated.
Last update: 2026-08-27 07:09:07 UTC
README
This package contains core functionality for HTTP health checking of Laravel services.
Usage
When the package is installed, a health endpoint, /vendor/service-health-checking is exposed. The endpoint
returns 200 OK and a body with a JSON data object with the following format:
{
"status": "pass|warn|fail",
"checks": [
{
"status": "pass|warn|fail",
"name": "HealthCheckClassName",
"description": "Description defined in the health check class",
"message": "Message set in the HealthStatus object"
}
]
}
The checks array contains an entry for each registered health check.
Authorization
The endpoints run the middleware stack from config('service-health-checking.middleware'),
which is empty by default — they are polled by monitoring, not a browser, so they carry no
session and no authorization gate.
To restrict who may poll them, publish the config (see below) and add middleware:
'middleware' => ['can:poll-health'],
Creating health checks
To create a health check for your service, simply create a class that extends
\Cego\ServiceHealthChecking\BaseHealthCheck. The base method has 2 abstract methods:
check(): HealthStatusshould perform the check and return aHealthStatusobject.getDescription(): stringshould return a description of the health check.
Registering health checks
Firstly, publish the package assets by running:
php artisan vendor:publish --provider="Cego\ServiceHealthChecking\ServiceHealthCheckingServiceProvider"
The package will publish a config file, service-health-checking.php, in which health check classes must be
registered, in order for them to run. A published config replaces the default registry entirely. A registry entry
that cannot be resolved is reported as a failing check.
Bundled health checks
| Check | Default registry | Purpose |
|---|---|---|
DefaultDatabaseConnectionCheck |
registered | Checks that a connection to the default database can be established |
CacheCheck |
opt-in | Checks read/write access to the cache |
Upgrading to 2.0
ActiveRequestInsurancesCheck,FailedRequestInsurancesCheckandServiceHealthConfigCheckhave been removed. Remove them, and therequest-insurancesection, from your publishedconfig/service-health-checking.php.CacheCheckis no longer registered by default. Add it to your registry if you want to keep running it.