PHPackages                             workerman/gatewayclient - 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. workerman/gatewayclient

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

workerman/gatewayclient
=======================

v3.1.1(1y ago)361282.3k—4.3%101[8 issues](https://github.com/walkor/GatewayClient/issues)20MITPHP

Since Dec 7Pushed 1y ago14 watchersCompare

[ Source](https://github.com/walkor/GatewayClient)[ Packagist](https://packagist.org/packages/workerman/gatewayclient)[ Docs](http://www.workerman.net)[ RSS](/packages/workerman-gatewayclient/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)DependenciesVersions (13)Used By (20)

GatewayClient
=============

[](#gatewayclient)

GatewayWorker1.0请使用[1.0版本的GatewayClient](https://github.com/walkor/GatewayClient/releases/tag/v1.0)

GatewayWorker2.0.1-2.0.4请使用[2.0.4版本的GatewayClient](https://github.com/walkor/GatewayClient/releases/tag/2.0.4)

GatewayWorker2.0.5-2.0.6版本请使用[2.0.6版本的GatewayClient](https://github.com/walkor/GatewayClient/releases/tag/2.0.6)

GatewayWorker2.0.7版本请使用 [2.0.7版本的GatewayClient](https://github.com/walkor/GatewayClient/releases/tag/v2.0.7)

GatewayWorker3.0.0-3.0.7版本请使用 [3.0.0版本的GatewayClient](https://github.com/walkor/GatewayClient/releases/tag/v3.0.0)

GatewayWorker3.0.8及以上版本请使用 [3.0.13版本的GatewayClient](https://github.com/walkor/GatewayClient/releases/tag/v3.0.13)

注意：GatewayClient3.0.0以后支持composer并加了命名空间`GatewayClient`

[如何查看GatewayWorker版本请点击这里](http://doc2.workerman.net/get-gateway-version.html)

安装
--

[](#安装)

**方法一**

```
composer require workerman/gatewayclient

```

使用时引入`vendor/autoload.php` 类似如下：

```
use GatewayClient\Gateway;
require_once '真实路径/vendor/autoload.php';
```

**方法二**下载源文件到任意目录，手动引入 `GatewayClient/Gateway.php`, 类似如下：

```
use GatewayClient\Gateway;
require_once '真实路径/GatewayClient/Gateway.php';
```

使用
--

[](#使用)

```
// GatewayClient 3.0.0版本以后加了命名空间
use GatewayClient\Gateway;

// composer安装
require_once '真实路径/vendor/autoload.php';

// 源文件引用
//require_once '真实路径/GatewayClient/Gateway.php';

/**
 * === 指定registerAddress表明与哪个GatewayWorker(集群)通讯。===
 * GatewayWorker里用Register服务来区分集群，即一个GatewayWorker(集群)只有一个Register服务，
 * GatewayClient要与之通讯必须知道这个Register服务地址才能通讯，这个地址格式为 ip:端口 ，
 * 其中ip为Register服务运行的ip(如果GatewayWorker是单机部署则ip就是运行GatewayWorker的服务器ip)，
 * 端口是对应ip的服务器上start_register.php文件中监听的端口，也就是GatewayWorker启动时看到的Register的端口。
 * GatewayClient要想推送数据给客户端，必须知道客户端位于哪个GatewayWorker(集群)，
 * 然后去连这个GatewayWorker(集群)Register服务的 ip:端口，才能与对应GatewayWorker(集群)通讯。
 * 这个 ip:端口 在GatewayClient一侧使用 Gateway::$registerAddress 来指定。
 *
 * === 如果GatewayClient和GatewayWorker不在同一台服务器需要以下步骤 ===
 * 1、需要设置start_gateway.php中的lanIp为实际的本机内网ip(如不在一个局域网也可以设置成外网ip)，设置完后要重启GatewayWorker
 * 2、GatewayClient这里的Gateway::$registerAddress的地址填写实际运行Register的服务器ip和端口
 * 3、需要开启GatewayWorker所在服务器的防火墙，让以下端口可以被GatewayClient所在服务器访问，
 *    端口包括Rgister服务的端口以及start_gateway.php中lanIp与startPort指定的几个端口
 *
 * === 如果GatewayClient和GatewayWorker在同一台服务器 ===
 * GatewayClient和Register服务都在一台服务器上，ip填写127.0.0.1及即可，无需其它设置。
 **/
Gateway::$registerAddress = '127.0.0.1:1236';

// GatewayClient支持GatewayWorker中的所有接口(Gateway::closeCurrentClient Gateway::sendToCurrentClient除外)
Gateway::sendToAll($data);
Gateway::sendToClient($client_id, $data);
Gateway::closeClient($client_id);
Gateway::isOnline($client_id);
Gateway::bindUid($client_id, $uid);
Gateway::isUidOnline($uid);
Gateway::isUidsOnline($uids);
Gateway::getClientIdByUid($uid);
Gateway::unbindUid($client_id, $uid);
Gateway::sendToUid($uid, $dat);
Gateway::joinGroup($client_id, $group);
Gateway::sendToGroup($group, $data);
Gateway::leaveGroup($client_id, $group);
Gateway::getClientCountByGroup($group);
Gateway::getClientSessionsByGroup($group);
Gateway::getAllClientCount();
Gateway::getAllClientSessions();
Gateway::setSession($client_id, $session);
Gateway::updateSession($client_id, $session);
Gateway::getSession($client_id);
```

###  Health Score

53

—

FairBetter than 96% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity56

Moderate usage in the ecosystem

Community36

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 89.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 ~269 days

Recently: every ~114 days

Total

12

Last Release

534d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c8bc354ebf6983ed6334dd25ad0c1003b0034bcd148111d2d7ef463171f4dcba?d=identicon)[workerman](/maintainers/workerman)

---

Top Contributors

[![walkor](https://avatars.githubusercontent.com/u/6073368?v=4)](https://github.com/walkor "walkor (75 commits)")[![xuanyanwow](https://avatars.githubusercontent.com/u/28777109?v=4)](https://github.com/xuanyanwow "xuanyanwow (5 commits)")[![hlxabcd](https://avatars.githubusercontent.com/u/2756343?v=4)](https://github.com/hlxabcd "hlxabcd (1 commits)")[![huangdijia](https://avatars.githubusercontent.com/u/8337659?v=4)](https://github.com/huangdijia "huangdijia (1 commits)")[![JoeZing](https://avatars.githubusercontent.com/u/5292292?v=4)](https://github.com/JoeZing "JoeZing (1 commits)")[![Yurunsoft](https://avatars.githubusercontent.com/u/20104656?v=4)](https://github.com/Yurunsoft "Yurunsoft (1 commits)")

### Embed Badge

![Health badge](/badges/workerman-gatewayclient/health.svg)

```
[![Health](https://phpackages.com/badges/workerman-gatewayclient/health.svg)](https://phpackages.com/packages/workerman-gatewayclient)
```

###  Alternatives

[stevebauman/location

Retrieve a user's location by their IP Address

1.3k8.5M90](/packages/stevebauman-location)[mediarox/module-checkout-placeholder

Show placeholders instead of labels at common checkout field's (incl. required entry mark).

111.5k](/packages/mediarox-module-checkout-placeholder)

PHPackages © 2026

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