PHPackages                             dionyang25/yii2-swoole-plugin - 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. dionyang25/yii2-swoole-plugin

ActiveLibrary[Framework](/categories/framework)

dionyang25/yii2-swoole-plugin
=============================

yii2 swoole 测试demo

0.1.1(8y ago)4211MITPHP

Since Dec 14Pushed 8y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (3)Used By (0)

yii2-swoole-plugin
==================

[](#yii2-swoole-plugin)

一个用于在swoole上运行yii2项目的composer包，类似的其实是有的，自己写了一个简单版的。

composer包安装
-----------

[](#composer包安装)

```
    composer require dionyang25/yii2-swoole-plugin
```

composer包地址
-----------

[](#composer包地址)

如何启动
----

[](#如何启动)

1. 配置console设置（config/console.php），在component中添加组件

```
    'yii2Swoole'=>[
        'class'=>'yii2Swoole\Server'
    ]
```

这里可以加入对swoole的配置，支持的配置如下（下图为默认配置）

```
    'yii2Swoole'=>[
        'class'=>'yii2Swoole\Server',
        'config'=>[
              'daemonize'=>0,
              'reactor_num'=>4,
              'worker_num'=>20,
              'max_request' => 100,
              'pid_file'=> __DIR__ . '/../../../runtime/server.pid'
        ]
    ]
```

2. 准备入口文件，该入口文件主要是设置你的YII应用服务器的启动参数，最终返回一个合并的启动数组配置即可

```
defined('YII_DEBUG') or define('YII_DEBUG',true);
defined('YII_ENV') or define('YII_ENV', 'dev');
$config = \yii\helpers\ArrayHelper::merge(
    require(__DIR__ . '/../config/web.php') ,
    require(__DIR__ . '/../config/web-local.php')
);

return $config;
```

3. 添加console启动控制器

```
namespace app\commands;
use yii\console\Controller;
use Yii;
/**
 * @author DionYang
 * @since 2.0
 */
class HelloController extends Controller
{
    /**
     * This command echoes what you have entered as the message.
     * @param string $message the message to be echoed.
     */
    public function actionIndex()
    {
        $server =Yii::$app->yii2Swoole;
        $server->entrance_file = __DIR__.'/../php-backstreet-api/index-test.php';
        $server->run();
    }

    public function actionStop()
    {
        $this->stdout('Already Stop'.PHP_EOL);
        Yii::$app->yii2Swoole->appStop();
    }
}
```

4. 需要修改nginx配置如下，注意，如果在yii2中启用pathinfo模式，那么三个额外的header必须要添加，否则无法正确匹配路由。 示例如下：

```
location ^~ /php-backstreet-api {
    root /Users/admin/www/php-backstreet-api;

    location ~ \.(css|js|jpg|png|gif)$ {
            root /Users/admin/www;
    }
    location ~ / {
        try_files $uri $uri/ /php-backstreet-api/index.php$is_args$args;
        #fastcgi_pass   127.0.0.1:9003;
        #fastcgi_index  index.php;
        #fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        #include        fastcgi_params;
            proxy_set_header request_uri $request_uri;
            proxy_set_header script_name $script_name;
            proxy_set_header script_filename $document_root$fastcgi_script_name;
            proxy_set_header Connection "keep-alive";
            proxy_set_header X-REAL-IP $remote_addr;
            proxy_pass http://127.0.0.1:9778;
    }
}
```

5. 控制台使用如下命令启动

```
./yii hello //启动
./yii hello/stop //终止
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity54

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

Total

2

Last Release

3067d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/955521f5bdd7fa316a668ec4bac70156c5a9f0dc79875d250c2f699dac6a263e?d=identicon)[dionyang25](/maintainers/dionyang25)

---

Tags

swooleyii2yii2-swooleswooleyii2yii2-swoole

### Embed Badge

![Health badge](/badges/dionyang25-yii2-swoole-plugin/health.svg)

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

###  Alternatives

[feehi/yii2-swoole

yii2 swoole,让yii2跑在swoole上

3458.3k1](/packages/feehi-yii2-swoole)[swoole-foundation/yii2-swoole-extension

running yii2 web application on swoole server

4312.3k1](/packages/swoole-foundation-yii2-swoole-extension)[easyswoole/orm

php stander lib

3088.7k17](/packages/easyswoole-orm)

PHPackages © 2026

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