PHPackages                             imiphp/imi-etcd - 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. imiphp/imi-etcd

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

imiphp/imi-etcd
===============

imi 框架 etcd 组件。imi etcd component.

2.1.x-dev(3y ago)501MulanPSL-2.0PHP

Since Aug 19Pushed 3y ago2 watchersCompare

[ Source](https://github.com/imiphp/imi-etcd)[ Packagist](https://packagist.org/packages/imiphp/imi-etcd)[ RSS](/packages/imiphp-imi-etcd/feed)WikiDiscussions 2.1 Synced 1mo ago

READMEChangelog (1)Dependencies (11)Versions (2)Used By (0)

imi-etcd
========

[](#imi-etcd)

[![Latest Version](https://camo.githubusercontent.com/99954e03b415c1886b8026f1d445960a7cb632ec2ba0cb380faf6299d697f9c9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f696d697068702f696d692d657463642e737667)](https://packagist.org/packages/imiphp/imi-etcd)[![Php Version](https://camo.githubusercontent.com/4a5c2ab20974058a8bab53ecb30ac4c2e6bb961df6229b7386fdc097ab53dfa8/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d2533453d372e342d627269676874677265656e2e737667)](https://secure.php.net/)[![Swoole Version](https://camo.githubusercontent.com/2b08ceed852c672ccac1ba1e0db0399fd6c269b1f40d58b8d4cf11455a95446d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f73776f6f6c652d2533453d342e382e302d627269676874677265656e2e737667)](https://github.com/swoole/swoole-src)[![imi License](https://camo.githubusercontent.com/98bdbfaa35e79370786c656980aab520be3e8af9551d8418a3ca4da1775f84c9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d756c616e50534c253230322e302d627269676874677265656e2e737667)](https://github.com/imiphp/imi-etcd/blob/2.1/LICENSE)

介绍
--

[](#介绍)

此项目是 imi 框架的 etcd 组件。

> 正在开发中，随时可能修改，请勿用于生产环境！

**支持的功能：**

- 配置中心

安装
--

[](#安装)

`composer require imiphp/imi-etcd:~2.1.0`

使用说明
----

[](#使用说明)

### 配置

[](#配置)

`@app.beans`：

```
use function Imi\env;
use Imi\Util\Imi;

[
    'ConfigCenter' => [
        // 'mode'    => \Imi\ConfigCenter\Enum\Mode::WORKER, // 工作进程模式
        'mode'    => \Imi\ConfigCenter\Enum\Mode::PROCESS, // 进程模式
        'configs' => [
            'etcd' => [
                'driver'  => \Imi\Etcd\Config\EtcdConfigDriver::class,
                // 客户端连接配置
                'client'  => [
                    'scheme'              => env('IMI_ETCD_SCHEME', 'http'), // http or https
                    'host'                => env('IMI_ETCD_HOST', '127.0.0.1'), // 主机名
                    'port'                => env('IMI_ETCD_PORT', 2379), // 端口号
                    'timeout'             => env('IMI_ETCD_TIMEOUT', 6000), // 网络请求超时时间，单位：毫秒
                    'ssl'                 => env('IMI_ETCD_SSL', false), // 是否使用 ssl(https) 请求
                    'version'             => env('IMI_ETCD_VERSION', 'v3'), /**
                     * v3 v3alpha v3beta v2
                     * etcd v3.2以及之前版本只使用[CLIENT-URL]/v3alpha/*。
                     * etcd v3.3使用[CLIENT-URL]/v3beta/*保持[CLIENT-URL]/v3alpha/*使用。
                     * etcd v3.4使用[CLIENT-URL]/v3/*保持[CLIENT-URL]/v3beta/*使用。
                     * [CLIENT-URL]/v3alpha/*被抛弃使用。
                     * etcd v3.5以及最新版本只使用[CLIENT-URL]/v3/*。
                     * [CLIENT-URL]/v3beta/*被抛弃使用。
                     */
                    'pretty'              => env('IMI_ETCD_PRETTY', true),
                    'sslCert'             => '',
                    'sslKey'              => ''
                ],
                // 监听器配置
                'listener' => [
                    'timeout'         => 30000, // 配置监听器长轮询超时时间，单位：毫秒
                    'failedWaitTime'  => 3000, // 失败后等待重试时间，单位：毫秒
                    'savePath'        => Imi::getRuntimePath('config-cache'), // 配置保存路径，默认为空不保存到文件。php-fpm 模式请一定要设置！
                    'fileCacheTime'   => 30, // 文件缓存时间，默认为0时不受缓存影响，此配置只影响 pull 操作。php-fpm 模式请一定要设置为大于0的值！
                    'pollingInterval' => 10000, // 客户端轮询间隔时间，单位：毫秒
                ],
                // 配置项
                'configs' => [
                    'etcd' => [
                        'key'  => 'imi-etcd-key1',
                    ],
                ],
            ],
        ],
    ],
]
```

### 获取配置

[](#获取配置)

```
\Imi\Config::get('etcd'); // 对应 imi-etcd-key1
```

### 写入配置

[](#写入配置)

```
/** @var \Imi\ConfigCenter\ConfigCenter $configCenter */
$configCenter = App::getBean('ConfigCenter');
$name = 'imi-etcd-key1';
$value = json_encode(['imi' => 'niubi']);
$options = [];
$configCenter->getDriver('etcd')->push($name, $value);
$configCenter->getDriver('etcd')->push($name, $value, $options);
```

免费技术支持
------

[](#免费技术支持)

QQ群：17916227 [![点击加群](https://camo.githubusercontent.com/75b53e353bb9e5064662e185a6d39f4bb88c4e45bd3a1240ddf599525edb6afa/68747470733a2f2f7075622e69647171696d672e636f6d2f7770612f696d616765732f67726f75702e706e67 "点击加群")](https://jq.qq.com/?_wv=1027&k=5wXf4Zq)，如有问题会有人解答和修复。

运行环境
----

[](#运行环境)

- [PHP](https://php.net/) &gt;= 7.4
- [Composer](https://getcomposer.org/) &gt;= 2.0
- [Swoole](https://www.swoole.com/) &gt;= 4.8.0
- [imi](https://www.imiphp.com/) &gt;= 2.1

版权信息
----

[](#版权信息)

`imi-etcd` 遵循 MulanPSL-2.0 开源协议发布，并提供免费使用。

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 Bus Factor1

Top contributor holds 90.9% 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 ~0 days

Total

2

Last Release

1368d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6f917bb42280d114c53cebadc2942a13ee03abe14971089f88895e266d637169?d=identicon)[Yurunsoft](/maintainers/Yurunsoft)

---

Top Contributors

[![ChrisLeeAreemm](https://avatars.githubusercontent.com/u/43305185?v=4)](https://github.com/ChrisLeeAreemm "ChrisLeeAreemm (60 commits)")[![Yurunsoft](https://avatars.githubusercontent.com/u/20104656?v=4)](https://github.com/Yurunsoft "Yurunsoft (6 commits)")

---

Tags

coroutineetcdphpswoole

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/imiphp-imi-etcd/health.svg)

```
[![Health](https://phpackages.com/badges/imiphp-imi-etcd/health.svg)](https://phpackages.com/packages/imiphp-imi-etcd)
```

###  Alternatives

[woutersioen/sir-trevor-php

A Sir Trevor to HTML conversion helper for PHP

2834.6k](/packages/woutersioen-sir-trevor-php)[naxon/laravel-url-uploaded-file

A package to leverage Laravel's UploadedFile functionality from URLs.

176.4k](/packages/naxon-laravel-url-uploaded-file)[dmitrykazak/magento-google-tag-manager

Google Tag Manager (GTM) Extension for Magento 2

112.8k](/packages/dmitrykazak-magento-google-tag-manager)

PHPackages © 2026

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