PHPackages                             cat-sys/swoole-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. [HTTP &amp; Networking](/categories/http)
4. /
5. cat-sys/swoole-etcd

ActiveLibrary[HTTP &amp; Networking](/categories/http)

cat-sys/swoole-etcd
===================

PHP Etcd v3 Client base on Swoole Http 2.0

0.1.1(9y ago)22821PHPPHP &gt;=5.5

Since May 13Pushed 9y ago1 watchersCompare

[ Source](https://github.com/CatsSystem/swoole-etcd)[ Packagist](https://packagist.org/packages/cat-sys/swoole-etcd)[ RSS](/packages/cat-sys-swoole-etcd/feed)WikiDiscussions master Synced 2w ago

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

swoole-etcd
===========

[](#swoole-etcd)

PHP Etcd v3 Client base on Swoole Http2 Client

Document
========

[](#document)

发起一个普通请求
--------

[](#发起一个普通请求)

```
// 连接到etcd服务器
$client = new KVClient('127.0.0.1:2379', []);
$client->connect(3, function($cli, $errCode) use ($client) {
    if($errCode != 0)
    {
        return;
    }
    $request = new PutRequest();
    $request->setKey("Hello");
    $request->setValue("test");
    $request->setPrevKv(true);
    $call = $client->Put($request);
    if($call)
    {
        $call->wait(function($result) use ($client){
            list($reply, $status) = $result;
            if($status != 200)
            {
                var_dump("Error");
                return;
            }
            if($reply instanceof \Etcdserverpb\PutResponse)
            {
                $item = $reply->getPrevKv();
                echo sprintf("update key[%s] success, pre value = %s\n", $item->getKey(), $item->getValue());
            }
        });
    } else {
        echo "request failed! Client closed\n";
    }
});
```

发起一个Watch请求
-----------

[](#发起一个watch请求)

在Etcd中，可以通过一个Watch命令来建立与服务器的双工通信。

```
// 连接到etcd服务器
$watch_client = new WatchClient('127.0.0.1:2379', []);
$watch_client->connect(3, function(WatchClient $client, $errCode) {
    if($errCode != 0)
    {
        return;
    }
    $call = $client->Watch();
    $call->waiting(function($result) use ($call, $client){
        list($response, $status) = $result;
        if($response->getCreated() || $response->getCanceled())
        {
            return;
        }
        foreach ($response->getEvents() as $event)
        {
            $type = $event->getType();
            switch($type)
            {
                case 0:
                {
                    $kv = $event->getKv();
                    echo sprintf("Put key[%s] = %s\n",  $kv->getKey(), $kv->getValue());

                    break;
                }
                case 1:
                {
                    break;
                }
            }
        }
        $call->close();
    });
    $request = new \Etcdserverpb\WatchRequest();
    $create = new \Etcdserverpb\WatchCreateRequest();
    $create->setKey("Hello");
    $request->setCreateRequest($create);
    $call->push($request);
});
```

依赖
==

[](#依赖)

- [Swoole扩展](https://github.com/swoole/swoole-src) 1.9.12 +
- [PHP-X](https://github.com/swoole/PHP-X) Latest Version
- [Http2 Client Extension](https://github.com/CatsSystem/swoole-extension) Latest Version

引入库
---

[](#引入库)

composer.json

```
{
    "require": {
        "cat-sys/swoole-etcd": "dev-master"
    }
}
```

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~13 days

Total

2

Last Release

3321d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/235d302f1bf927ede884773311f8fd819bf736a9641babe81a5cd67fc1468768?d=identicon)[LinkedDestiny](/maintainers/LinkedDestiny)

---

Top Contributors

[![LinkedDestiny](https://avatars.githubusercontent.com/u/5689061?v=4)](https://github.com/LinkedDestiny "LinkedDestiny (2 commits)")

### Embed Badge

![Health badge](/badges/cat-sys-swoole-etcd/health.svg)

```
[![Health](https://phpackages.com/badges/cat-sys-swoole-etcd/health.svg)](https://phpackages.com/packages/cat-sys-swoole-etcd)
```

###  Alternatives

[google/gax

Google API Core for PHP

268111.6M516](/packages/google-gax)[google/common-protos

Google API Common Protos for PHP

174112.8M64](/packages/google-common-protos)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

84735.1k](/packages/flow-php-flow)[xingwenge/canal_php

connect canal server via php client.

39896.9k2](/packages/xingwenge-canal-php)[spiral/roadrunner-grpc

High-Performance GRPC server for PHP applications

652.9M16](/packages/spiral-roadrunner-grpc)[swoole/grpc

Grpc PHP Client base on Swoole Http2 Coroutine

19719.7k1](/packages/swoole-grpc)

PHPackages © 2026

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