PHPackages                             mix/json-rpc - 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. mix/json-rpc

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

mix/json-rpc
============

JSON-RPC library based on Swoole coroutine, including server and client, supports both TCP and HTTP protocols

v2.2.14(5y ago)74373Apache-2.0PHPPHP &gt;=7.0.0CI failing

Since Jan 14Pushed 5y ago1 watchersCompare

[ Source](https://github.com/mix-php/json-rpc)[ Packagist](https://packagist.org/packages/mix/json-rpc)[ Docs](https://openmix.org/)[ RSS](/packages/mix-json-rpc/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependencies (9)Versions (15)Used By (3)

Mix JSON-RPC
------------

[](#mix-json-rpc)

基于 Swoole 协程的 JSON-RPC 库，包含服务器、客户端，同时支持 TCP、HTTP 两种协议，并具有微服务调用功能

Usage
-----

[](#usage)

安装：

- Swoole &gt;= 4.4.4:

```
composer require mix/json-rpc

```

- Service

首先定义一个服务

```
class Calculator
{
    public const NAME = "php.micro.jsonrpc.calculator.Calculator";

    public function Sum(int $a, int $b): int
    {
        return array_sum([$a, $b]);
    }
}

```

- Server

创建服务器，并注册 Calculator 服务

```
$server  = new \Mix\JsonRpc\Server('127.0.0.1', 9234);
$class = Calculator::class;
$server->register($class);
$server->start();

```

扩展 HTTP 支持

```
$http = new \Mix\Http\Server\Server('127.0.0.1', 9235);
$http->start($server);

```

- Client 调用

创建客户端

```
$dialer = new \Mix\JsonRpc\Client\Dialer();
$conn   = $dialer->dial('127.0.0.1', 9234);

$request = (new \Mix\JsonRpc\Factory\RequestFactory)->createRequest('Calculator.Sum', [1, 3], 100001)
$response = $conn->call($request);
var_dump($response);

```

- Client 微服务调用

```
$dialer = new \Mix\JsonRpc\Client\Dialer([
    'registry' => new \Mix\Micro\Etcd\Registry('http://127.0.0.1:2379/v3'),
]);
$conn   = $dialer->dialFromService('php.micro.jsonrpc.calculator');

$request = (new \Mix\JsonRpc\Factory\RequestFactory)->createRequest('Calculator.Sum', [1, 3], 100001)
$response = $conn->call($request);
var_dump($response);

```

License
-------

[](#license)

Apache License Version 2.0,

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity59

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 ~19 days

Recently: every ~29 days

Total

14

Last Release

2072d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/16074765?v=4)[LIU JIAN](/maintainers/onanying)[@onanying](https://github.com/onanying)

---

Top Contributors

[![onanying](https://avatars.githubusercontent.com/u/16074765?v=4)](https://github.com/onanying "onanying (81 commits)")

---

Tags

httpclientservertcpswoolecoroutinejsonrpcjson-rpcmix

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mix-json-rpc/health.svg)

```
[![Health](https://phpackages.com/badges/mix-json-rpc/health.svg)](https://phpackages.com/packages/mix-json-rpc)
```

###  Alternatives

[hhxsv5/laravel-s

🚀 LaravelS is an out-of-the-box adapter between Laravel/Lumen and Swoole.

3.9k676.0k10](/packages/hhxsv5-laravel-s)[swow/swow

Coroutine-based multi-platform support engine with a focus on concurrent I/O

1.3k2.1M84](/packages/swow-swow)[swlib/saber

Swoole coroutine HTTP client

985145.0k27](/packages/swlib-saber)[datto/json-rpc-http

HTTP client and server for JSON-RPC 2.0

66525.9k5](/packages/datto-json-rpc-http)[swoole/grpc

Grpc PHP Client base on Swoole Http2 Coroutine

19718.9k1](/packages/swoole-grpc)[swoole/etcd-client

Grpc PHP Client base on Swoole Http2 Coroutine

1973.2k1](/packages/swoole-etcd-client)

PHPackages © 2026

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