PHPackages                             chj/swoole-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. chj/swoole-rpc

ActiveLibrary

chj/swoole-rpc
==============

swoole4.5+ 协程RPC服务

v1.4.0(5y ago)056MITPHPPHP &gt;=7.2

Since Nov 18Pushed 5y ago1 watchersCompare

[ Source](https://github.com/chenhuojia/swoole-rpc)[ Packagist](https://packagist.org/packages/chj/swoole-rpc)[ RSS](/packages/chj-swoole-rpc/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (7)Used By (0)

HJRPC
=====

[](#hjrpc)

基于swoole协程封装的一个rpc服务,路由注册
-------------------------

[](#基于swoole协程封装的一个rpc服务路由注册)

\##安装

- composer require chj/swoole-rpc

\##使用

### 开启服务

[](#开启服务)

```
include  '../vendor/autoload.php';
/**
* 开启TCP(9501)&HTTP(8090)服务
**/
$server = new chj\Swoole\Coroutine\Server\Server();
//配置
$server->initSetting([
        'http' =>[
            'host' => '0.0.0.0',
            'port' => 8090,
        ],
        'tcp' =>[
            'host' => '0.0.0.0',
            'port' => 9501,
        ],
        'custom' =>[
            'tcpPack' => 'length',    // 1.eof，eof拆包 2.length，length拆包
        ],
        // 服务注册
        'serviceRegisterSetting' =>[
            'host' => '127.0.0.1',
            'port' => 6379,
            'serviceName' => 'account-service',
        ],
]);
//运行服务
$server->run();
```

### 客户端

[](#客户端)

连接服务

```
include  '../vendor/autoload.php';

$client = \chj\Swoole\Coroutine\Client\RpcClient::getInstance(['host'=>'0.0.0.0','port'=>'6667']);

$data = $client->login('chj','login');

print_r($data);
```

### 注册路由

[](#注册路由)

要在服务启动前注册路由

```
include  '../vendor/autoload.php';
chj\Swoole\Library\Router::group(['namespace' => 'Application\Controller'], function ($route) {
    $route::add('login','Account@login');
    $route::add('login2','Account@login2');
    $route::add('getUserByName', function ($name,$tes) {
        return 'name: ' . $name;
    });
    $route::add('getUserByName2', function ($name) {
        return 'name: ' . $name;
    });
});
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

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

Total

6

Last Release

1875d ago

### Community

Maintainers

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

---

Tags

rpcswoole

### Embed Badge

![Health badge](/badges/chj-swoole-rpc/health.svg)

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

PHPackages © 2026

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