govigilant/laravel-healthchecks
Composer 安装命令:
composer require govigilant/laravel-healthchecks
包简介
A Laravel package to add healthchecks which can be integrated with govigilant.io
README 文档
README
Vigilant Laravel Healthchecks
A package that adds healthchecks to any Laravel application and integrates seamlessly with Vigilant.
Features
This package provides an API endpoint to check the health of your Laravel application. It returns two types of checks, health checks and metrics. Healthchecks are checks that indicate whether a specific part of your application is functioning correctly, while metrics provide numeric values that give insights on health over time. Vigilant can use these metrics to notify you of spikes or quickly increasing metrics.
Installation
Install the package via Composer:
composer require govigilant/laravel-healthchecks
Configuration
Set the API token in your .env file:
VIGILANT_HEALTHCHECK_TOKEN=your-vigilant-api-key-here
Note: The token is required to access the health endpoint.
Optionally publish the configuration if you want to adjust default behavior:
php artisan vendor:publish --provider="Vigilant\LaravelHealthchecks\ServiceProvider"
This creates config/vigilant-healthchecks.php.
Scheduler
This package automatically schedules a command and a job to verify if your scheduler and queue workers are running.
If you do not want or want to customize this behavior, you can disable the automatic scheduling in the config file by setting schedule to false.
Ensure to schedule the php artisan vigilant:scheduler-heartbeat yourself if you disable automatic scheduling.
Usage
Accessing the Health Endpoint
Once installed, the health check endpoint is available with your configured bearer token at:
POST /api/vigilant/health
Or using curl:
curl -X POST "YOUR_URL_HERE/api/vigilant/health" \
-H "Authorization: Bearer YOUR_BEARER_TOKEN" \
-H "Content-Type: application/json"
Registering Checks and Metrics
Register health checks and metrics in your AppServiceProvider's boot method.
Note: The package comes with defaults, so you may not need to register any checks or metrics manually when having the
registersetting enabled in the config file.
use Vigilant\LaravelHealthchecks\Facades\HealthCheck; use Vigilant\LaravelHealthchecks\Checks\DatabaseCheck; use Vigilant\LaravelHealthchecks\Checks\CacheCheck; use Vigilant\LaravelHealthchecks\Checks\RedisCheck; use Vigilant\LaravelHealthchecks\Checks\HorizonCheck; use Vigilant\LaravelHealthchecks\Checks\SchedulerCheck; use Vigilant\LaravelHealthchecks\Checks\Metrics\CpuLoadMetric; use Vigilant\LaravelHealthchecks\Checks\Metrics\MemoryUsageMetric; use Vigilant\LaravelHealthchecks\Checks\Metrics\DiskUsageMetric; public function boot(): void { HealthCheck::registerCheck(DatabaseCheck::make()); HealthCheck::registerCheck(CacheCheck::make()); HealthCheck::registerCheck(RedisCheck::make()); HealthCheck::registerCheck(HorizonCheck::make()); HealthCheck::registerCheck(SchedulerCheck::make()); HealthCheck::registerMetric(CpuLoadMetric::make()); HealthCheck::registerMetric(MemoryUsageMetric::make()); HealthCheck::registerMetric(DiskUsageMetric::make()); }
Configuring Specific Connections
If you want to check non-default connections you can register healthchecks yourself in your service provider.
use Vigilant\LaravelHealthchecks\Facades\HealthCheck; use Vigilant\LaravelHealthchecks\Checks\DatabaseCheck; use Vigilant\LaravelHealthchecks\Checks\CacheCheck; use Vigilant\LaravelHealthchecks\Checks\RedisCheck; public function boot(): void { // Check a specific database connection HealthCheck::registerCheck(DatabaseCheck::make()->connection('mysql')); // Check a specific cache store HealthCheck::registerCheck(CacheCheck::make()->store('redis')); // Check a specific Redis connection HealthCheck::registerCheck(RedisCheck::make()->connection('sessions')); }
Check availability
Each healthcheck checks if it is applicable in the current environment. For example, the HorizonCheck will only run if Laravel Horizon is installed.
If a check is not applicable, it will be skipped and not included in the results. You may override this behaviour by registering the check manually can calling the alwaysRun method.
Available Checks
| Check | Description |
|---|---|
| DatabaseCheck | Verifies database connection and query execution |
| CacheCheck | Tests cache read/write operations |
| RedisCheck | Verifies Redis connection health |
| RedisMemoryCheck | Monitors Redis max memory usage |
| QueueCheck | Checks queue workers are processing jobs |
| HorizonCheck | Verifies Laravel Horizon is running |
| SchedulerCheck | Ensures Laravel scheduler is active |
| StorageCheck | Validates storage directory permissions |
| DebugModeCheck | Warns if debug mode is enabled in production |
Available Metrics
| Metric | Description |
|---|---|
| CpuLoadMetric | Current CPU load average |
| MemoryUsageMetric | System memory usage percentage |
| DiskUsageMetric | Disk space usage percentage |
| DatabaseSizeMetric | Total database size |
| LogFileSizeMetric | Laravel log file size |
Development Environment
A ready-to-use Docker-based development environment lives in devenv/.
Ensure Docker is running, then start the stack: docker compose -f devenv/docker-compose.yml up --build.
This will create a Laravel application, link this package for development, and set the bearer token to testing, which can be used to access the health endpoint:
curl -X POST "http://localhost:8000/api/vigilant/health" \ -H "Authorization: Bearer testing" \ -H "Content-Type: application/json"
Quality
Run the quality checks:
composer quality
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
govigilant/laravel-healthchecks 适用场景与选型建议
govigilant/laravel-healthchecks 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 578 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 11 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「healthchecks」 「vigilant」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 govigilant/laravel-healthchecks 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 govigilant/laravel-healthchecks 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 govigilant/laravel-healthchecks 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Bundle for integration with healthchecks.io cron monitoring service
A simple PHP healthchecks.io wrapper
Base package for integrating healthchecks
Alfabank REST API integration
Monitor Laravel Backups with Healthchecks.
Laravel package that integrates Healthchecks.io to monitor queue and mail-server availability and provides a configurable ping URL builder.
统计信息
- 总下载量: 578
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 26
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-11-30