PHPackages                             panwenbin/yii2-on-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. [Framework](/categories/framework)
4. /
5. panwenbin/yii2-on-swoole

ActiveYii2-extension[Framework](/categories/framework)

panwenbin/yii2-on-swoole
========================

run yii2 on swoole server

0.1.1(7y ago)015MITPHPPHP &gt;=7.0.0

Since Jul 19Pushed 7y ago1 watchersCompare

[ Source](https://github.com/panwenbin/yii2-on-swoole)[ Packagist](https://packagist.org/packages/panwenbin/yii2-on-swoole)[ RSS](/packages/panwenbin-yii2-on-swoole/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (2)Dependencies (1)Versions (6)Used By (0)

安装
--

[](#安装)

```
composer require panwenbin/yii2-on-swoole

```

使用
--

[](#使用)

```
$ vendor/bin/yii2onswoole
usage: vendor/bin/yii2onswoole (start|stop|reload) $app $port

```

参数解释

- start|stop|reload 启动、停止、热重启
- $app - 是指运行哪个应用，高级版模板有frontend和backend，基础版模板留空
- $port - 监听的端口，默认8000

如果基础版模板要指定端口

```
$ vendor/bin/yii2onswoole start '' 8001

```

worker\_bootstrap.php
---------------------

[](#worker_bootstrapphp)

第一次运行会复制启动配置文件到根目录 `worker_bootstrap.php`，此文件在worker启动时调用，修改它可以定义YII\_DEBUG等，或者替换组件

```
defined('YII_DEBUG') or define('YII_DEBUG', false); // 如果不定义则是true
defined('YII_ENV') or define('YII_ENV', 'prod'); // 如果不定义则是dev
```

worker\_stop.php
----------------

[](#worker_stopphp)

在Yii项目的根目录建立`worker_stop.php`，worker进程正常退出时调用

程序编写注意事项
--------

[](#程序编写注意事项)

- 使用Yii2推荐的写法编写程序
- 不能使用exit()/die()，它会结束worker进程
- 不要使用php内置session函数，已封装RedisSession
- 不要使用php内置cookie函数，已封装到Response，或者直接操作Swoole的Response
- 不要使用echo/print/print\_f/var\_dump输出页面内容，他们只会在控制台输出内容
- 不要使用static变量存储内容，它会在下次请求到来时产生干扰

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

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

Total

2

Last Release

2844d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9246abb5bc6b21062bebdd5685fb7eda856f3208707e743b848d97a62d81935e?d=identicon)[panwenbin](/maintainers/panwenbin)

---

Top Contributors

[![panwenbin](https://avatars.githubusercontent.com/u/19491104?v=4)](https://github.com/panwenbin "panwenbin (11 commits)")

### Embed Badge

![Health badge](/badges/panwenbin-yii2-on-swoole/health.svg)

```
[![Health](https://phpackages.com/badges/panwenbin-yii2-on-swoole/health.svg)](https://phpackages.com/packages/panwenbin-yii2-on-swoole)
```

###  Alternatives

[skeeks/cms

SkeekS CMS — control panel and tools based on php framework Yii2

13825.6k47](/packages/skeeks-cms)

PHPackages © 2026

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