Skip to content

friendsofhyperf/confd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

confd

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