153264/think-health

Health check for ThinkPHP

V1.2.0 2025-08-25 00:19 UTC

This package is auto-updated.

Last update: 2025-09-25 00:35:06 UTC


README

📦 一个为 ThinkPHP 框架设计的健康检查库,支持自定义健康检查和灵活的配置选项。

Lint Status Latest Stable Version Latest Unstable Version Total Downloads License

功能特性

  • 简单易用的健康检查接口
  • 可自定义的健康检查
  • 灵活的配置选项
  • 支持使用命令行定时上报健康情况

环境需求

安装

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