pandtit / health_check
A configurable health check endpoint for Laravel with IP whitelist support.
Installs: 50
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/pandtit/health_check
Requires
- php: ^7.1.3|^7.2|^7.3|^7.4
- illuminate/config: ^5.6|^6.0|^7.0|^8.0
- illuminate/http: ^5.6|^6.0|^7.0|^8.0
- illuminate/routing: ^5.6|^6.0|^7.0|^8.0
- illuminate/support: ^5.6|^6.0|^7.0|^8.0
- symfony/http-foundation: ^4.3|^5.0
Requires (Dev)
- laravel/framework: ^5.6|^5.8|^6.0|^7.0|^8.0
- orchestra/testbench: ^3.6|^4.0|^5.0|^6.0|^7.0
- phpunit/phpunit: ^7.5|^8.5|^9.0|^10.0
README
Laravel Health Check
Laravel Health Check: Monitors database/cache/queue connectivity with IP whitelist security, providing real-time status checks via API endpoints.
Laravel 健康监控包:通过 API 端点实时监测数据库/缓存/队列的连通性状态,支持 IP 白名单访问控制,确保关键服务可用性。
Installation
# 安装包
composer require Pandtit/health_check
publish config
php artisan vendor:publish --provider="Pandtit\HealthCheck\HealthCheckServiceProvider" --tag="config"
Environment Configuration
You can configure via .env:
# 启用健康检查 HEALTH_CHECK_ENABLED=true # 允许访问检查接口的IP,逗号分隔 HEALTH_CHECK_IPS=127.0.0.1,192.168.1.0/24,10.0.0.1 # 允许支持代理 HEALTH_CHECK_IPS_ALLOW_PROXY=false # 是否检查更多 HEALTH_CHECK_DB_ENABLED=false HEALTH_CHECK_CACHE_ENABLED=false HEALTH_CHECK_QUEUE_ENABLED=false # 是否记录日志,默认开启 HEALTH_CHECK_LOG_ENABLED=true # 是否开启频次限制,默认开启 HEALTH_CHECK_RATE_LIMIT_ENABLED=true HEALTH_CHECK_MAX_ATTEMPTS=60 HEALTH_CHECK_DECAY_MINUTES=1
usage
access: get http://your-app/api/health
healthy
simple
{
"errcode": 0,
"errmsg": null,
"status": "healthy",
"data": [],
"at": "2025-07-30T02:12:32.063030Z",
"service": "your_app"
}
multiple
{
"errcode": 0,
"errmsg": null,
"status": "healthy",
"data": {
"database": "healthy",
"cache": "healthy",
"queue": "healthy"
},
"at": "2025-07-29T04:03:21.436347Z",
"service": "your_app"
}
unhealty
{
"errcode": 0,
"errmsg": "Queue check failed",
"status": "unhealthy",
"data": {
"database": "unhealthy",
"cache": "unhealthy",
"queue": "unhealthy"
},
"at": "2025-07-29T06:41:07.036335Z",
"service": "your_app"
}
not in ip
status 403
{"errcode":403,"errmsg":"Forbidden"}