PHPackages                             vzina/jsonrpc - 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. vzina/jsonrpc

ActiveLibrary[API Development](/categories/api)

vzina/jsonrpc
=============

Webman plugin vzina/jsonrpc

00PHP

Since Jan 8Pushed 5mo agoCompare

[ Source](https://github.com/vzina/webman-jsonrpc)[ Packagist](https://packagist.org/packages/vzina/jsonrpc)[ RSS](/packages/vzina-jsonrpc/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Webman JSON RPC
===============

[](#webman-json-rpc)

#### 定义服务端

[](#定义服务端)

> 服务进程配置 **process.php**

```
return [
    'jsonrpc' => [
        'handler' => Vzina\Jsonrpc\Server::class,
        // 服务端协议配置 => 客户端协议配置
        // 'json://0.0.0.0:8788' => 'json://127.0.0.1:8788'
        // 'http://0.0.0.0:8788' => 'http://127.0.0.1:8788'
        'listen' => 'http://0.0.0.0:8788',
        'count' => cpu_count() * 4,
        'user' => '',
        'group' => '',
        'reusePort' => false,
        'eventLoop' => Workerman\Events\Fiber::class, // 建议使用协程功能
        'context' => [],
        'constructor' => [
            'requestClass' => Vzina\Jsonrpc\Request::class,
            'logger' => support\Log::channel(),
            'appPath' => app_path()
        ]
    ]
]
```

```
namespace app\Service;

use Vzina\Jsonrpc\Attribute\RpcServer;

#[RpcServer]
class TestService
{
    public function rpc(): array
    {
        return ['test', time()];
    }
}
```

#### 定义客户端

[](#定义客户端)

```
namespace app\Client;

use support\Container;
use Vzina\Jsonrpc\Ast\AbstractProxyService;use Vzina\Jsonrpc\ServiceClient;

class TestService
{
    protected ServiceClient $serviceClient;

    public function __construct()
    {
        $this->serviceClient = new ServiceClient(static::class, [
            'address' => ['http://127.0.0.1:8788'],
            'timeout' => 60,
            'pool' => [
                'max_connections' => 10,
            ]
        ]);
    }

    public function rpc(): array
    {
        return $this->serviceClient->__call(__FUNCTION__, func_get_args());
    }
}

// 或
class TestService extends AbstractProxyService
{
    public function rpc(): array
    {
        return $this->client->__call(__FUNCTION__, func_get_args());
    }
}

// 修改配置文件 rpc_services.php
[
    'name' => TestService::class, // 指定客户端类
    // ... other
]

// 使用
$r = Container::get(TestService::class)->rpc();
var_dump($r);
```

#### 定义自动客户端

[](#定义自动客户端)

```
namespace app\contracts;

interface TestServiceInterface
{
    public function rpc(): array;
}

// 修改配置文件 rpc_services.php
[
    'auto_services' => app_path('contracts'), // 指定客户端扫描目录
    // ... other
]

// 使用
$r = Container::get(TestServiceInterface::class)->rpc();
var_dump($r);
```

###  Health Score

16

—

LowBetter than 4% of packages

Maintenance48

Moderate activity, may be stable

Popularity0

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity13

Early-stage or recently created project

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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7343318?v=4)[weijian.ye](/maintainers/vzina)[@vzina](https://github.com/vzina)

### Embed Badge

![Health badge](/badges/vzina-jsonrpc/health.svg)

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

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35916.4M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24016.2M20](/packages/hubspot-api-client)[pocketmine/bedrock-protocol

An implementation of the Minecraft: Bedrock Edition protocol in PHP

172445.0k15](/packages/pocketmine-bedrock-protocol)[botman/driver-telegram

Telegram driver for BotMan

93459.5k6](/packages/botman-driver-telegram)

PHPackages © 2026

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