The confd component for Hyperf.

Fund package maintenance!
huangdijia
hdj.me/sponsors

Installs: 18 333

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

pkg:composer/friendsofhyperf/confd


README

Latest Stable Version Total Downloads License

The confd component for Hyperf.

Requirements

  • PHP >= 8.0
  • Hyperf >= 3.0

Installation

composer require friendsofhyperf/confd
composer require friendsofhyperf/etcd
# or
composer require friendsofhyperf/nacos

Command

Fetch configs from etcd/nacos and upgrade .env.

php bin/hyperf.php confd:env

Listener

<?php

namespace App\Listener;

use FriendsOfHyperf\Confd\Event\ConfigChanged;
use Hyperf\Contract\StdoutLoggerInterface;
use Hyperf\Event\Annotation\Listener;
use Hyperf\Event\Contract\ListenerInterface;

#[Listener()]
class ConfigChangedListener implements ListenerInterface
{
    public function __construct(private StdoutLoggerInterface $logger)
    {
    }

    public function listen(): array
    {
        return [
            ConfigChanged::class,
        ];
    }

    public function process(object $event): void
    {
        $this->logger->warning('[confd] ConfdChanged');
        // do something
    }
}

Support

  • Etcd
  • Nacos
  • Consul

Contact

License

MIT