PHPackages                             thinkcmf/cmf-swoole - 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. thinkcmf/cmf-swoole

ActiveCmf-extend

thinkcmf/cmf-swoole
===================

Swoole extend for ThinkCMF5.1

v5.1.4(7y ago)371.8k↓100%15[4 issues](https://github.com/thinkcmf/cmf-swoole/issues)Apache-2.0PHP

Since Feb 24Pushed 3y ago5 watchersCompare

[ Source](https://github.com/thinkcmf/cmf-swoole)[ Packagist](https://packagist.org/packages/thinkcmf/cmf-swoole)[ RSS](/packages/thinkcmf-cmf-swoole/feed)WikiDiscussions 5.1 Synced 1mo ago

READMEChangelog (5)Dependencies (4)Versions (7)Used By (0)

ThinkCMF Swoole 扩展
==================

[](#thinkcmf-swoole-扩展)

本扩展是基于`topthink/think-swoole`优化，方便ThinkCMF用户快速使用上swoole，原则上你可以使用相同的代码同时支持`PHP-FPM`和`Swoole`。 它让你的项目同时拥有swoole的高性能和ThinkPHP快速开发的特性，你可以开发高性能的API服务，也可以拥有 websocket。

安装 swoole
---------

[](#安装-swoole)

详细的 swoole安装可以参考swoole官方文档，

安装 ThinkCMF
-----------

[](#安装-thinkcmf)

详细的ThinkCMF安装可以参考ThinkCMF安装文档，[https://www.kancloud.cn/thinkcmf/doc5\_1/957743](https://www.kancloud.cn/thinkcmf/doc5_1/957743)

安装 cmf-swoole扩展
---------------

[](#安装-cmf-swoole扩展)

```
composer require thinkcmf/cmf-swoole:~5.1.0

```

启动 swoole
---------

[](#启动-swoole)

cd到程序根目录，执行如下命令：

```
php think swoole

```

swoole启动后会输出如下内容：

```
Starting swoole http server...
Swoole http server started: http://0.0.0.0:9501;
You can exit with `CTRL-C`

```

此时 swoole就启动成功了！ swoole默认端口是9501，监听所有 ip。在浏览器中输入 swoole所在主机的 ip加端口9501，就可以访问页面了。 如果想关闭，只要按 `CTRL+C`组合键就可以关闭 swoole了。

守护进程方式启动 swoole
---------------

[](#守护进程方式启动-swoole)

同样cd到程序根目录，但要执行如下命令：

```
php think swoole -d

```

此 swoole会以后台守护进程的方式运行，要想停止 swoole就要使用下面的命名了：

```
php think swoole stop

```

指定IP和端口号
--------

[](#指定ip和端口号)

默认IP是`0.0.0.0`，默认端口是`9501`

### 指定swoole IP

[](#指定swoole-ip)

```
php think swoole -H 127.0.0.1

```

或

```
php think swoole --host=127.0.0.1

```

### 指定swoole端口

[](#指定swoole端口)

```
php think swoole -p 9502

```

或

```
php think swoole --port=9502

```

重启 swoole
---------

[](#重启-swoole)

```
php think swoole restart

```

优雅重载swoole
----------

[](#优雅重载swoole)

此种方式会平滑地重启所有 worker进程

```
php think swoole reload

```

Swoole API
==========

[](#swoole-api)

启动 swoole api服务
---------------

[](#启动-swoole-api服务)

swoole下 RESTful和普通 web服务是分开的；默认 IP:`0.0.0.0`，默认端口:`9502`

```
php think swoole:api

```

同样支持守护模式

```
php think swoole:api -d

```

指定 IP和端口

```
php think swoole:api -d -p 9502 -H 127.0.0.1

```

停止api服务

```
php think swoole:api  stop

```

重启api服务

```
php think swoole:api   restart

```

重载api服务

```
php think swoole:api    reload

```

项目案例
----

[](#项目案例)

### ThinkCMF WebSocket Demo:

[](#thinkcmf-websocket-demo)

WebSocket演示插件

更新日志
----

[](#更新日志)

### 5.1.4

[](#514)

- 增加`swoole_server_start`,`swoole_worker_start`,`swoole_websocket_on_open`,`swoole_websocket_on_close`钩子
- 增加`WebSocket`独立运行命令
- 增加`WebSocket onOpen`回调
- 修复`WebSocket`事件引起的数据库执行报错
- 修复`WebSocket`发送消息未判断是否为`WebSocket`连接
- 增加`worker`进程启动时自动初始化所有模块

### 5.1.3

[](#513)

- 修复文件更改后worker重启后部分请求cookie报错
- 修复data/config目录不存在时文件定时刷新报错
- 修复无法识别?s=app/controller/action路径
- `gitignore`过滤 composer.lock文件

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 96.3% 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 ~213 days

Recently: every ~317 days

Total

7

Last Release

1351d ago

Major Versions

5.1.x-dev → 6.0.x-dev2022-08-27

### Community

Maintainers

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

---

Top Contributors

[![simplewindorg](https://avatars.githubusercontent.com/u/6101935?v=4)](https://github.com/simplewindorg "simplewindorg (26 commits)")[![thinkcmf](https://avatars.githubusercontent.com/u/6211558?v=4)](https://github.com/thinkcmf "thinkcmf (1 commits)")

### Embed Badge

![Health badge](/badges/thinkcmf-cmf-swoole/health.svg)

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

###  Alternatives

[zoujingli/think-library

Library for ThinkAdmin

8569.8k17](/packages/zoujingli-think-library)[yunwuxin/think-notification

The Notification Library For ThinkPHP6

422.2k4](/packages/yunwuxin-think-notification)

PHPackages © 2026

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