think-health
think-health 是一个开源的 ThinkPHP 非官方 SDK。
安装非常简单,因为它是一个标准的 Composer 包,这意味着任何满足下列安装条件的 PHP 项目支持 Composer 都可以使用它。
环境需求
- PHP >= 8.2
- PHP cURL 扩展
- ThinkPHP 8.x
安装
WARNING
不建议使用第三方的 Composer 源
请使用 官方源 安装
shell
composer require 153264/think-health
使用
http 检查
默认情况下,你可以通过访问 /health
路径来进行健康检查:
bash
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
进行健康检查。
INFO
默认不进行上报,如果需要上报可以使用 --report
选项
bash
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 |
+--------------------------------------------+--------------------------------------------------------------------------------------------+
开始之前
在你动手写代码之前,建议您首先阅读以下内容:
参与贡献
我们欢迎广大开发者贡献大家的智慧,让我们共同让它变得更完美。
您可以在 GitHub 上提交 Pull Request,我们会尽快审核并公布。
更多信息请参考 贡献指南。