Hyperf provider for php-actuator.
Via Composer
$ composer require kilofox/php-actuator-hyperf-provider
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
- 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.
The MIT License (MIT). Please see License File for more information.