kylofox/ php-actuator-hyperf-provider
php-actuator 的 Hyperf 提供者
v1.0.0
2022-01-24 09:51 UTC
Requires
- php: ^7.4|^8.0
- postalservice14/php-actuator: ^1.0
This package is auto-updated.
Last update: 2024-09-24 16:58:53 UTC
README
php-actuator 的 Hyperf 提供者。
安装
通过 Composer
$ composer require kilofox/php-actuator-hyperf-provider
用法
设置你想要进行健康检查的路由。例如:
Router::addRoute(['GET'], '/health', 'App\Controller\IndexController@health');
然后访问你的端点。在本例中: /health
入门
- 创建 /app/Controller/IndexController.php
<?php namespace App\Controller; use Hyperf\Di\Annotation\Inject; use Kilofox\Actuator\HealthServiceProvider; class IndexController extends AbstractController { /** * @Inject * @var HealthServiceProvider */ private $health; public function index() { $memcached = new \Memcached(); $memcached->addServer('127.0.0.1', 11211); return $this->health ->addIndicator('disk') ->addIndicator('memcached', $memcached) ->getHealth($this->response); } }
- 运行服务
php bin/hyperf.php start
- 前往 https://:9501/health 查看你的健康指标。
许可证
MIT 许可证 (MIT)。有关更多信息,请参阅许可证文件。