PHPackages                             choir/choir - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. choir/choir

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

choir/choir
===========

PHP 写的 Socket Server 库

0.1.2-alpha(3y ago)5491MITPHPPHP ^7.4 || ^8.0 || ^8.1

Since Nov 18Pushed 3y agoCompare

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

READMEChangelog (3)Dependencies (9)Versions (4)Used By (0)

Choir
=====

[](#choir)

一个纯 PHP 写的 Socket Server 和 Socket Client 库，由 Workerman 改进而来，作为一个学习的项目而编写。

Choir 的功能
---------

[](#choir-的功能)

Choir 内部使用 PHP 原生的 Socket Server 实现了一个 TCP 和 UDP 的服务器，在此基础上实现了 HTTP、WebSocket 等协议，可以使用 Choir 来实现一个纯 CLI 环境下的 Web 应用服务。

Choir 基于部分 Workerman 的代码，功能与 Workerman 相似，但相较于底层的信号处理、包处理以及开放接口采用更加通用的 PSR 标准，便于融合其他框架。

Choir 文档
--------

[](#choir-文档)

> 在写了在写了。

与 Workerman 的不同
---------------

[](#与-workerman-的不同)

### 1. 重构目录结构

[](#1-重构目录结构)

Choir 重构了 Workerman 的 Worker 结构，采用 Server 对象对服务进行描述，同时单个 Server 可以监听不同的端口，从最开始统一了 Web Server 的概念。

### 2. 完善 WebSocket 协议实现

[](#2-完善-websocket-协议实现)

对 WebSocket 协议实现来说，Workerman 仅实现了 UTF-8 明文，Choir 实现了支持二进制传输及分包传输，更支持了一些额外的 WebSocket 操作对象，例如 Frame 等。

### 3. 重构协议层接口

[](#3-重构协议层接口)

重构协议层的接口，对协议的解析流程进行了调整。

此外，Choir 对协议的实现均统一，即 Server 和 Client 同一套解析逻辑，Client 默认异步，在开启协程后可异步转协程同步。

### 4. 支持协程

[](#4-支持协程)

原生支持 Fiber 协程一键开启，使用 PHP 8.1 时自动开启纤程，且可通过传入的配置项切换使用 Swoole、Swow 协程库等。

### 5. 源码清晰

[](#5-源码清晰)

Choir 源码的每一部分都添加了注释，你可以在查看 Choir 源码的过程中快速了解它是如何运作的。

### 6. 开放性和易用性并存

[](#6-开放性和易用性并存)

Choir 同 Workerman 一样，默认提供了一些初始的参数显示和信号处理参数，但 Choir 可以通过传参和修改静态变量的方式进行自定义。

Choir 的不足
---------

[](#choir-的不足)

Choir 目前仅实现了基础的 Server 和 Client 组件，其他附带的组件暂时正在开发中。

Choir 暂无法直接整合其他 Workerman 现成组件，后期会添加适配器。

HTTP 服务器样例
----------

[](#http-服务器样例)

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

// 也可以使用 Url 模式：$server = new \Choir\Server("http://0.0.0.0:20001");
$server = new \Choir\Http\Server('0.0.0.0', 20001, false, [
    'worker-num' => 8,
]);

$server->on('request', function (Choir\Protocol\HttpConnection $connection) {
    $connection->end('hello world');
});

$server->start();
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

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

Total

3

Last Release

1246d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8bbf5705e9f35b31cbba478f9fbae0b6da2211348ecd41689cd2e4230c77a3e1?d=identicon)[crazywhalecc](/maintainers/crazywhalecc)

---

Top Contributors

[![crazywhalecc](https://avatars.githubusercontent.com/u/20330940?v=4)](https://github.com/crazywhalecc "crazywhalecc (28 commits)")

---

Tags

phpswooleworkermanchoir

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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