PHPackages                             buexplain/netsvr-business-coroutine - 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. buexplain/netsvr-business-coroutine

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

buexplain/netsvr-business-coroutine
===================================

这是一个基于hyperf框架开发的，可以快速开发websocket全双工通信业务的包，它基于https://github.com/buexplain/netsvr进行工作。

v4.0.1(11mo ago)26Apache-2.0PHPPHP &gt;=8.1

Since Dec 23Pushed 11mo ago1 watchersCompare

[ Source](https://github.com/buexplain/netsvr-business-coroutine)[ Packagist](https://packagist.org/packages/buexplain/netsvr-business-coroutine)[ RSS](/packages/buexplain-netsvr-business-coroutine/feed)WikiDiscussions main Synced yesterday

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

netsvr-business-coroutine
=========================

[](#netsvr-business-coroutine)

这是一个基于hyperf框架开发的，可以快速开发websocket全双工通信业务的包，它基于进行工作。

ps：如果你的项目是非协程的，串行执行php代码的，则可以使用这个包：

使用步骤
----

[](#使用步骤)

1. 下载并启动网关服务：，该服务会启动：websocket服务器、worker服务器
2. 在hyperf项目里面安装本包以及protobuf包：
    - composer require buexplain/netsvr-business-coroutine
    - composer require google/protobuf
3. 发布配置文件：`php bin/hyperf.php vendor:publish buexplain/netsvr-business-coroutine`
4. 修改配置文件`config/autoload/netsvr.php`，把里面的`workerAddr`配置项，改为网关服务的worker服务器地址，另外在`app/Event.php`处理网关转发的事件，添加你的业务逻辑。
5. 执行启动命令：`php bin/hyperf.php start`
6. 搜索一个在线测试websocket的网页，连接到网关服务的websocket服务器，发送消息：`你好`，可以看到消息回显

本包的三种使用方式
---------

[](#本包的三种使用方式)

### 如果你的项目需要接收网关主动发过来的消息，则你可以采用以下两种方式：

[](#如果你的项目需要接收网关主动发过来的消息则你可以采用以下两种方式)

1. 直接启动，执行启动命令：`php bin/hyperf.php business:start`，另外要注意：此方式只运行在`swoole`驱动的hyperf下执行，且在cygwin版本swoole-cli下，无法使用hyperf框架的Db、redis组件。
2. 跟随http服务器启动，配置文件`listeners.php`添加配置`\NetsvrBusiness\Listener\StartMainSocketListener::class`。

### 如果你的项目不需要接收网关主动发过来的消息

[](#如果你的项目不需要接收网关主动发过来的消息)

你不需要做任何启动动作，直接使用`\NetsvrBusiness\NetBus`提供的静态方法与网关交互，此方式只能实现服务器主动下发数据到客户端，客户端无法发送消息给你的进程。

进程停止时候优雅断开与网关的连接
----------------

[](#进程停止时候优雅断开与网关的连接)

- 如果你的项目安装了`composer require hyperf/signal`包,则配置文件`signal.php`必须添加配置`\NetsvrBusiness\Handler\StopHandler::class=>1`。
- 没有安装，则不必做任何配置,本包的`\NetsvrBusiness\Listener\CloseListener::class`会自行处理。

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance50

Moderate activity, may be stable

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity56

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

Recently: every ~86 days

Total

7

Last Release

356d ago

Major Versions

v1.0.0 → v2.0.02024-07-28

v2.0.2 → v3.0.02024-11-10

v3.0.0 → v4.0.02025-02-13

### Community

Maintainers

![](https://www.gravatar.com/avatar/3b5d9484a14b3718c89b908f5dfc3560c4cbf0c4a879ea77a53c708aead2b2f4?d=identicon)[buexplain](/maintainers/buexplain)

---

Top Contributors

[![buexplain](https://avatars.githubusercontent.com/u/12883364?v=4)](https://github.com/buexplain "buexplain (15 commits)")

---

Tags

coroutinehyperfnetsvrphpswooleswowwebsocketphpwebsocketswoolecoroutinehyperfswownetsvr

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/buexplain-netsvr-business-coroutine/health.svg)

```
[![Health](https://phpackages.com/badges/buexplain-netsvr-business-coroutine/health.svg)](https://phpackages.com/packages/buexplain-netsvr-business-coroutine)
```

###  Alternatives

[symfony/symfony

The Symfony PHP framework

31.4k87.2M2.2k](/packages/symfony-symfony)[hyperf/hyperf

A coroutine framework that focuses on hyperspeed and flexibility. Building microservice or middleware with ease.

6.9k3.3k2](/packages/hyperf-hyperf)[nelmio/api-doc-bundle

Generates documentation for your REST API from attributes

2.4k67.4M263](/packages/nelmio-api-doc-bundle)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[ecotone/ecotone

Enterprise architecture layer for Laravel and Symfony — CQRS, Event Sourcing, Durable Workflows (Sagas, Orchestrators), Projections, and Outbox messaging via PHP attributes.

564576.7k52](/packages/ecotone-ecotone)[wikimedia/parsoid

Parsoid, a bidirectional parser between wikitext and HTML5

187557.3k3](/packages/wikimedia-parsoid)

PHPackages © 2026

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