kilofox / php-actuator-hyperf-provider
Hyperf provider for php-actuator
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-10-24 17:10:05 UTC
README
Hyperf provider for php-actuator.
Install
Via Composer
$ composer require kilofox/php-actuator-hyperf-provider
Usage
Setup the route you would like your health check on. e.g.:
Router::addRoute(['GET'], '/health', 'App\Controller\IndexController@health');
Then visit your endpoint. In this case: /health
Getting Started
- Create /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); } }
- Run the service
php bin/hyperf.php start
- Go to http://localhost:9501/health to see your health indicator.
License
The MIT License (MIT). Please see License File for more information.