PHPackages                             sanyateam/3y-jsonrpc-client - 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. [API Development](/categories/api)
4. /
5. sanyateam/3y-jsonrpc-client

ActiveProject[API Development](/categories/api)

sanyateam/3y-jsonrpc-client
===========================

基于Tcp的JsonRpc2.0客户端

0.0.7(5y ago)1205MITPHPPHP &gt;=7.2.0

Since Oct 9Pushed 5y ago1 watchersCompare

[ Source](https://github.com/sanyateam/3y-jsonrpc-client)[ Packagist](https://packagist.org/packages/sanyateam/3y-jsonrpc-client)[ RSS](/packages/sanyateam-3y-jsonrpc-client/feed)WikiDiscussions master Synced 5d ago

READMEChangelog (7)Dependencies (1)Versions (8)Used By (0)

wm-jsonrpc-client
=================

[](#wm-jsonrpc-client)

---

A JsonRpc-client for WorkerMan

- 基于TCP协议通讯
- JsonRpc-2.0业务协议
- 适用于PHP-FPM/PHP-CLI的jsonRpc 应-答 模式客户端
- ext-sockets、ext-json

---

1.阻塞调用
------

[](#1阻塞调用)

- 业务会等待服务器业务应答结果

#### 1. 请求 call(method, arguments, id)

[](#1-请求-callmethod-arguments-id)

- method (string) \[必要\]: 调用方式
- arguments (array) \[必要\]: 参数
- id (string) \[非必要\]: ID **该项不传入时，为通知类型请求**

```
# Notice
$res = RpcClient::instance(['tcp://localhost:5252'])->call(
    'Server.UserServer.getUser',
    ['call' => 'Server.UserServer.getUser']
);

# request
$res = RpcClient::instance(['tcp://localhost:5252'])->call(
    'Server.UserServer.getUser',
    ['call' => 'Server.UserServer.getUser'],
    RpcClient::uuid()
);

```

2.拆分请求
------

[](#2拆分请求)

- 业务无须阻塞等待等待服务器业务应答结果
- 业务拆分为发送、接收
- 在PHP-FPM下仅可在一个上下文中使用发送-接收异步执行业务
- 在workerman/swoole下，只要进程不退出，都可以使用发送-接收执行业务

#### 1. 发送请求 asyncSend(method, arguments, id)

[](#1-发送请求-asyncsendmethod-arguments-id)

- method (string) \[必要\]: 调用方式
- param (array) \[必要\]: 参数
- id (string) \[必要\]: ID

**注：**

- 在接收前重复的同个ID执行，会抛出一个MethodAlreadyException异常

```
# request
try {
    $rpc = RpcClient::instance(['tcp://localhost:5252']);
    [$key1, $res] = $rpc->asyncSend(
        'Test.Test.demo',
        ['async' => 'send1'],
        RpcClient::uuid()
    );

    # 如果是重复的ID，则会抛出一个MethodAlreadyException异常
    [$key2, $res] = $rpc->asyncSend(
        'Test.Test.demo',
        ['async' => 'send2'],
        RpcClient::uuid()
    );

    [$key3, $res] = $rpc->asyncSend(
        'Test.Test.demo',
        ['async' => 'send3'],
        RpcClient::uuid()
    );
}catch(\JsonRpc\Exception\MethodAlreadyException $methodAlreadyException){

}

```

#### 2. 发送通知 asyncNoticeSend(method, arguments, sole = true)

[](#2-发送通知-asyncnoticesendmethod-arguments-sole--true)

- method (string) \[必要\]: 调用方式
- param (array) \[必要\]: 参数
- sole (bool) \[非必要\]: 是否开启调用方式唯一执行

**注：**

- 如果开启调用方式唯一执行，在执行接收前重复同个method会抛出一个MethodAlreadyException异常

```
# request
try {
    [$key, $res] = $rpc->asyncNoticeSend(
        'Test.Test.demo',
        ['async' => 'notice_send'],
        true
    );

    # 如果开启调用方式唯一执行，以下会抛出一个MethodAlreadyException异常
    [$key, $res] = $rpc->asyncNoticeSend(
        'Test.Test.demo',
        ['async' => 'notice_send'],
        true
    );

}catch(\JsonRpc\Exception\MethodAlreadyException $methodAlreadyException){

}

```

#### 3. 接收 asyncRecv(key)

[](#3-接收-asyncrecvkey)

- key (string) \[必要\]: 发送方式返回的key值

**注：**

- 如果调用的key值不存在，会抛出一个MethodNotReadyException异常
- 成功调用后，会将key值失效

```
# request
try {
    # 如果调用的key值不存在，则会抛出一个MethodNotReadyException异常
    [$tag, $data] = $rpc->asyncRecv($key);

}catch(\JsonRpc\Exception\MethodNotReadyException $methodAlreadyException){

}

```

---

补充
--

[](#补充)

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 56.7% 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

7

Last Release

1965d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/71683613?v=4)[sanyateam](/maintainers/sanyateam)[@sanyateam](https://github.com/sanyateam)

---

Top Contributors

[![chaz6chez](https://avatars.githubusercontent.com/u/22535862?v=4)](https://github.com/chaz6chez "chaz6chez (17 commits)")[![sanyateam](https://avatars.githubusercontent.com/u/71683613?v=4)](https://github.com/sanyateam "sanyateam (13 commits)")

---

Tags

tcpjsonrpcworkerman

### Embed Badge

![Health badge](/badges/sanyateam-3y-jsonrpc-client/health.svg)

```
[![Health](https://phpackages.com/badges/sanyateam-3y-jsonrpc-client/health.svg)](https://phpackages.com/packages/sanyateam-3y-jsonrpc-client)
```

###  Alternatives

[sergeyfast/eazy-jsonrpc

PHP JSON-RPC 2.0 Server/Client Implementation with SMD &amp; Swagger support

6164.2k](/packages/sergeyfast-eazy-jsonrpc)[drlecks/simple-web3-php

Web3 library in PHP

7641.6k2](/packages/drlecks-simple-web3-php)[tochka-developers/jsonrpc

JsonRpc extension for Laravel

2733.8k1](/packages/tochka-developers-jsonrpc)[smileymrking/laravel-gateway-worker

GatewayWorker SDK for Laravel

161.8k](/packages/smileymrking-laravel-gateway-worker)

PHPackages © 2026

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