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 4mo agoCompare

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

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

18

—

LowBetter than 8% of packages

Maintenance55

Moderate activity, may be stable

Popularity0

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity12

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://www.gravatar.com/avatar/248f8ed7469cedfe37c86e79cff2ab49e9f3379b416f29bdf2460527dabfd1ed?d=identicon)[vzina](/maintainers/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

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M475](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M270](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M186](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M33](/packages/facebook-php-business-sdk)[microsoft/microsoft-graph

The Microsoft Graph SDK for PHP

65723.5M95](/packages/microsoft-microsoft-graph)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)

PHPackages © 2026

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