kilofox/php-actuator-hyperf-provider

Hyperf provider for php-actuator

v1.0.0 2022-01-24 09:51 UTC

This package is auto-updated.

Last update: 2024-04-24 16:04:53 UTC


README

Release Version Latest Release Download Total Download

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);
    }

}

License

The MIT License (MIT). Please see License File for more information.