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

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

kriss/yii2-thread
=================

yii2 multi thread with fsockopen

1.1(9y ago)43502MITPHP

Since Jul 14Pushed 9y ago1 watchersCompare

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

READMEChangelog (2)Dependencies (1)Versions (3)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 验证，默认开启
        'tokenParam' => 'token', // 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

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 73.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 ~304 days

Total

2

Last Release

3333d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b4053cfc9956b8c15b9bc4c9c7c2bad625d16d1b6d9191019b2a25cc0972d955?d=identicon)[kriss](/maintainers/kriss)

---

Top Contributors

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

---

Tags

yii2-extensionyii2Thread

### Embed Badge

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

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

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M2.9k](/packages/craftcms-cms)[dmstr/yii2-cookie-consent

Yii2 Cookie Consent Widget

1454.6k](/packages/dmstr-yii2-cookie-consent)[imanilchaudhari/yii2-currency-converter

This extension will help to find out current currency conversion rate.

1911.7k](/packages/imanilchaudhari-yii2-currency-converter)

PHPackages © 2026

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