153264 / think-health
Health check for ThinkPHP
Installs: 16
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Type:module
pkg:composer/153264/think-health
Requires
- php: >=8.2.0
- topthink/framework: ^6.1.5|^8.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.67
- phpstan/phpstan: ^2.1
README
📦 一个为 ThinkPHP 框架设计的健康检查库,支持自定义健康检查和灵活的配置选项。
功能特性
- 简单易用的健康检查接口
- 可自定义的健康检查
- 灵活的配置选项
- 支持使用命令行定时上报健康情况
环境需求
- PHP >= 8.2.0
- Composer >= 2.0
安装
composer require 153264/think-health
使用示例
安装后,健康检查接口会自动注册到你的应用中。
默认情况下,你可以通过访问 /health
路径来进行健康检查:
curl http://your-domian/your-entrance/health
服务正常
HTTP/1.1 200 OK
Content-Type: text/html
ok
服务异常
HTTP/1.1 500 Internal Server Error
Content-Type: text/html
error
也可以通过命令行 health:check
进行健康检查。
默认不进行上报,如果需要上报可以使用 --report
选项
php think health:check +--------------------------------------------+--------------------------------------------------------------------------------------------+ | Name | Message | +--------------------------------------------+--------------------------------------------------------------------------------------------+ | CheckDataBase | SQLSTATE[HY000] [1045] Access denied for user 'username'@'localhost' (using password: YES) | | CheckCache | ok | | CheckEnv | APP_DEBUG is not falsy | | CheckFolder | ok | | CheckHttp https://your-server.com/resource | request failed with status code: 0 | +--------------------------------------------+--------------------------------------------------------------------------------------------+
文档和链接
License
MIT