PHPackages                             friendsofhyperf/config-consul - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. friendsofhyperf/config-consul

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

friendsofhyperf/config-consul
=============================

The consul config component for Hyperf.

v3.2.0(3w ago)03191MITPHP

Since May 21Pushed 2w ago1 watchersCompare

[ Source](https://github.com/friendsofhyperf/config-consul)[ Packagist](https://packagist.org/packages/friendsofhyperf/config-consul)[ Fund](https://hdj.me/sponsors/)[ GitHub Sponsors](https://github.com/huangdijia)[ RSS](/packages/friendsofhyperf-config-consul/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (10)Dependencies (8)Versions (102)Used By (0)

Config Consul
=============

[](#config-consul)

[中文说明](README_CN.md)

A Consul configuration center driver for Hyperf.

Installation
------------

[](#installation)

```
composer require friendsofhyperf/config-consul
```

The package installs its Hyperf Config Center, Consul, codec, and stringable dependencies automatically.

Configuration
-------------

[](#configuration)

```
// config/autoload/config_center.php

return [
    'enable' => true,
    'driver' => 'consul',
    'drivers' => [
        'consul' => [
            'driver' => FriendsOfHyperf\ConfigConsul\ConsulDriver::class,
            'packer' => Hyperf\Codec\Packer\JsonPacker::class,
            'client' => [
                'uri' => env('CONSUL_URI'),
                'token' => env('CONSUL_TOKEN'),
            ],
            'namespaces' => [
                '/application',
            ],
            'mapping' => [
                // consul key => config key
                '/application/test' => 'test',
            ],
            'interval' => 5,
        ],
    ],
];
```

OptionDescription`enable`Enables Hyperf Config Center.`driver`Selects the `consul` driver configuration.`drivers.consul.driver`The driver class. Use `ConsulDriver::class`.`drivers.consul.packer`Unpacks each mapped value. Defaults to `JsonPacker::class`.`drivers.consul.client`Optional Consul client settings. Supports `uri` and `token`.`drivers.consul.namespaces`An array of Consul KV prefixes to fetch recursively.`drivers.consul.mapping`Maps normalized Consul keys to Hyperf configuration keys. Only mapped keys are applied.`drivers.consul.interval`Pull interval in seconds. Defaults to `5`.If `client` is omitted or empty, the component reuses Hyperf's bound `Hyperf\Consul\KVInterface` client. When `client` is configured, `uri` defaults to `http://127.0.0.1:8500`, a non-empty `token` is sent as the `X-Consul-Token` header, and the HTTP timeout is 2 seconds.

Behavior
--------

[](#behavior)

- Every namespace is requested with Consul's recursive option. If namespaces return the same key, the value from the later namespace wins before mapping.
- Consul KV values are Base64-decoded, then passed to the configured packer. With `JsonPacker`, stored values must contain valid JSON after Base64 decoding.
- Consul keys are normalized to start with `/` before lookup in `mapping`.
- The package registers `FriendsOfHyperf\ConfigConsul\ClientInterface` and `FriendsOfHyperf\ConfigConsul\Consul\KVInterface` in the container. `ConsulDriver` is the Config Center driver entry point.

###  Health Score

49

—

FairBetter than 94% of packages

Maintenance96

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 98.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~15 days

Recently: every ~48 days

Total

101

Last Release

26d ago

Major Versions

v2.0.1 → v3.0.0-beta22022-05-23

v2.0.3 → v3.0.0-beta92022-05-24

v2.0.11 → v3.0.0-beta302022-06-24

v2.0.24 → v3.0.02022-12-29

2.0.x-dev → v3.0.142023-02-10

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8337659?v=4)[Deeka Wong](/maintainers/huangdijia)[@huangdijia](https://github.com/huangdijia)

---

Top Contributors

[![huangdijia](https://avatars.githubusercontent.com/u/8337659?v=4)](https://github.com/huangdijia "huangdijia (58 commits)")[![liuchenrang](https://avatars.githubusercontent.com/u/2784214?v=4)](https://github.com/liuchenrang "liuchenrang (1 commits)")

---

Tags

hyperfv3.2

### Embed Badge

![Health badge](/badges/friendsofhyperf-config-consul/health.svg)

```
[![Health](https://phpackages.com/badges/friendsofhyperf-config-consul/health.svg)](https://phpackages.com/packages/friendsofhyperf-config-consul)
```

###  Alternatives

[hyperf/watcher

Hot reload watcher for Hyperf

17904.9k31](/packages/hyperf-watcher)[hyperf/http-server

A HTTP Server for Hyperf.

103.0M371](/packages/hyperf-http-server)[hyperf/di

A DI for Hyperf.

173.0M691](/packages/hyperf-di)[friendsofhyperf/lock

The lock component for Hyperf.

1453.6k](/packages/friendsofhyperf-lock)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
