PHPackages                             nerburish/yii2-thread - 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. nerburish/yii2-thread

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

nerburish/yii2-thread
=====================

yii2 multi thread with fsockopen

1.0(9y ago)16MITPHP

Since Jul 14Pushed 9y ago1 watchersCompare

[ Source](https://github.com/nerburish/yii2-thread)[ Packagist](https://packagist.org/packages/nerburish/yii2-thread)[ Docs](https://github.com/krissss/yii2-thread)[ RSS](/packages/nerburish-yii2-thread/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

yii2 multi thread
=================

[](#yii2-multi-thread)

yii2 使用 fsockopen 模拟多线程操作

安装
--

[](#安装)

推荐使用 [composer](http://getcomposer.org/download/).

```
php composer.phar require --prefer-dist kriss/yii2-thread "*"

```

或添加下面代码到`composer.json`文件

```
"kriss/yii2-thread": "*"

```

然后使用

```
php composer.phar update

```

使用方式
----

[](#使用方式)

1.进行配置

basic 模版为 config/web.php, advanced 模版为对应入口的 config/main.php

示例配置如下：

```
'components' => [
    ...
    'thread' => [
        'class' => 'kriss\thread\components\Thread',
        'enable' => true,
        'tokenValidate' => true, // 是否开启 url token 验证，默认开启
        'token' => 'suiyitianxiezijidetoken', // 随意填写自己的验证 token
    ],
    ...
]
```

2.继承和改写

编写控制器来接收异步处理的链接

继承 `\kriss\thread\controllers\WebThreadController` 然后编写对应的 Action

3.使用

比如控制器下有个 Action 如下:

```
public function actionSendMessage($message)
{
    Yii::info($message);
}
```

则在需要调用异步处理的脚本中使用：

```
Yii::$app->thread->addThread(['/web-thread/send-message','message'=>'hello world']);
```

链接`['/web-thread/send-message','message'=>'hello world']`将会在"本次请求脚本执行结束之前"（参考：[register\_shutdown\_function](http://php.net/register_shutdown_function)） 使用`fsockopen`方式发起请求访问

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 54.5% 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

Unknown

Total

1

Last Release

3638d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/15d8609efafa1febdf2ebc686337c3f7c75596c97b98bce385e9290ce7bce5b0?d=identicon)[nerburish](/maintainers/nerburish)

---

Top Contributors

[![krissss](https://avatars.githubusercontent.com/u/10680903?v=4)](https://github.com/krissss "krissss (6 commits)")[![nerburish](https://avatars.githubusercontent.com/u/5610788?v=4)](https://github.com/nerburish "nerburish (5 commits)")

---

Tags

yii2Thread

### Embed Badge

![Health badge](/badges/nerburish-yii2-thread/health.svg)

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

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M2.9k](/packages/craftcms-cms)[yiisoft/yii2-app-advanced

Yii 2 Advanced Project Template

1.7k960.6k5](/packages/yiisoft-yii2-app-advanced)[yiisoft/yii2-redis

Redis Cache, Session and ActiveRecord for the Yii framework

44912.1M264](/packages/yiisoft-yii2-redis)[yiisoft/yii2-httpclient

HTTP client extension for the Yii framework

43011.4M323](/packages/yiisoft-yii2-httpclient)[yiisoft/yii2-debug

The debugger extension for the Yii framework

20324.2M616](/packages/yiisoft-yii2-debug)[yiisoft/yii2-app-basic

Yii 2 Basic Project Template

6761.8M8](/packages/yiisoft-yii2-app-basic)

PHPackages © 2026

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