phpsafari/health-checks
Composer 安装命令:
composer require phpsafari/health-checks
包简介
Make health checks in your laravel application
README 文档
README
Add health checks to your Laravel applications with this package.
Examples
Install
First, use Composer to install this package.
$ composer require phpsafari/health-checks
After the package has been installed, go ahead and add ``PhpSafari\ServiceProvider\HealthCheckServiceProvider::classto yourconfig/app.php` file.
After doing this, you can publish the health.php configuration file into your config folder by running:
$ php artisan vendor:publish --tag=health
Usage
Inside the config/health.php file is where you configure all your available health checks. By default, this package comes packed with a few checks already:
CorrectEnvironmentwill check if your application's environment is set toproductionDatabaseOnlinewill check your database connectionDatabaseUpToDatewill check if your application has any migrations that hasn't been migrated yetDebugModeOffwill check if debug mode is offQueueProcessingwill check if the queue is running and jobs are getting processedPathIsWritablewill check if a provided path is writableLogLevelwill check if log level is set to the given valueMaxRatioOf500Responseswill check if the ratio of 500 response are above a given threshold (The last 60 min)MaxResponseTimeAvgwill check if average response time for all request are above a given threshold (The last 60 min)
To run a health check of your application, run:
$ php artisan health:check
You can also use Laravel's scheduler to schedule your health checks:
$schedule->command('health:check')->hourly();
Url based health checks
You can also run a health check by hitting the https://<APP_URL>/_health url in a browser or with a tool like Pingdom.
Note: _This feature can be disabled in the config/health.php file, by setting route.enabled to false.
You can navigate to https://<APP_URL>/_health/stats and get all stats, including avg response time,
Creating your own health checks
In order to create your own health checks, you just need to extend the PhpSafari\Checks\HealthCheck class and implement the run() method.
Example:
class IsFriday extends PhpSafari\Checks\HealthCheck { public function run(): bool { return Carbon::now()->isFriday(); } }
Then add new IsFriday() to the list of checks in config/health.php.
Testing
$ phpunit tests/
Security
If you discover any security related issues, please email :author_email instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
phpsafari/health-checks 适用场景与选型建议
phpsafari/health-checks 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 13.17k 次下载、GitHub Stars 达 37, 最近一次更新时间为 2017 年 08 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 phpsafari/health-checks 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 phpsafari/health-checks 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 13.17k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 37
- 点击次数: 18
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-08-17



