📦 一个为 ThinkPHP 框架设计的健康检查库,支持自定义健康检查和灵活的配置选项。
- 简单易用的健康检查接口
- 可自定义的健康检查
- 灵活的配置选项
- 支持使用命令行定时上报健康情况
- PHP >= 8.2.0
- Composer >= 2.0
composer require 153264/think-health安装后,健康检查接口会自动注册到你的应用中。
默认情况下,你可以通过访问 /health 路径来进行健康检查:
curl http://your-domian/your-entrance/healthHTTP/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 |
+--------------------------------------------+--------------------------------------------------------------------------------------------+MIT