itmosoft / laravel-health
Extensible health checks for Laravel applications.
Requires
- php: ^8.3
- illuminate/console: ^12.0|^13.0
- illuminate/contracts: ^12.0|^13.0
- illuminate/database: ^12.0|^13.0
- illuminate/filesystem: ^12.0|^13.0
- illuminate/http: ^12.0|^13.0
- illuminate/support: ^12.0|^13.0
Requires (Dev)
- orchestra/testbench: ^10.0|^11.0
- phpunit/phpunit: ^12.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Extensible health checks for Laravel 12 and 13 applications.
Requirements
- PHP 8.3+
- Laravel 12 or 13
Installation
composer require itmosoft/laravel-health php artisan vendor:publish --tag=health-config
The package is auto-discovered by Laravel.
Run checks
php artisan health:check php artisan health:check --json
The command exits with a non-zero status when a critical check fails.
Built-in checks
- Application bootstrap and environment metadata
- PHP runtime version and memory limit
- Database connection and
SELECT 1 - Cache write/read/delete probe
- Configured filesystem write/read/delete probe
- Pending application migrations
Cache and storage probes use unique temporary keys/files and best-effort cleanup. Configure the storage disk with HEALTH_STORAGE_DISK or health.storage.disk.
Register custom checks
Implement ItmoSoft\Health\Contracts\HealthCheck:
use ItmoSoft\Health\Contracts\HealthCheck; use ItmoSoft\Health\DTOs\HealthCheckResult; class StoreConfigurationCheck implements HealthCheck { public function name(): string { return 'store-configuration'; } public function run(): HealthCheckResult { return config('app.name') ? HealthCheckResult::healthy($this->name(), 'Store configuration is available.') : HealthCheckResult::warning($this->name(), 'Application name is not configured.'); } }
Register it in an application service provider:
use ItmoSoft\Health\Facades\Health; Health::register(StoreConfigurationCheck::class);
Or add the class to health.checks in config/health.php.
JSON endpoints
Endpoints are disabled by default. To enable:
// config/health.php 'endpoint' => [ 'enabled' => true, 'path' => 'health', 'middleware' => ['api'], 'liveness_path' => 'health/live', 'readiness_path' => 'health/ready', ],
GET /health: complete health summaryGET /health/live: process liveness onlyGET /health/ready: readiness based on configured checks
Protect detailed endpoints with suitable middleware or network-level access controls before enabling them publicly. Liveness does not run dependency checks. The status endpoint returns HTTP 503 for critical status; warning/unknown currently return HTTP 200.
Result statuses
healthy, warning, critical, unknown.
Health results intentionally avoid returning exception messages or secrets. Exceptions are reported to the application's configured logger.
Configuration
Publish the config with php artisan vendor:publish --tag=health-config.
health.checks: check classes to runhealth.database.probe: enable database query probehealth.database.check_migrations: inspect pending application migrationshealth.cache.probe: enable cache probehealth.storage.disk: storage disk to probe; defaults to filesystem defaulthealth.storage.probe: enable storage probehealth.endpoint: optional HTTP endpoints
Testing
composer install
composer test
Security notes
- Do not expose detailed health endpoints publicly without access controls.
- Health check messages should not contain credentials, tokens, SQL, or exception traces.
- Storage probes write a short-lived random file and attempt cleanup.
- This package does not implement a web dashboard or persistent history in v1.0.0.
License
MIT.