PHPackages                             qbhy/swoole-parallel - 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. qbhy/swoole-parallel

ActiveLibrary

qbhy/swoole-parallel
====================

v1.1(5y ago)1377PHPPHP &gt;=7.2

Since Jun 15Pushed 5y ago1 watchersCompare

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

READMEChangelog (3)Dependencies (1)Versions (4)Used By (0)

swoole-parallel
---------------

[](#swoole-parallel)

可以并行执行协程的库，摘自 hyperf/utils 由于hyperf/utils 的 parallel 只能在 hyperf 框架下面使用，所以有了这个项目。

安装 - install
------------

[](#安装---install)

```
$ composer require qbhy/swoole-parallel
```

使用 - usage
----------

[](#使用---usage)

```
require __DIR__ . 'vendor/autoload.php';

\Swoole\Coroutine::create(function () {
    $time = time();
    $parallel = new \Qbhy\SwooleParallel\Parallel(20);

//    $parallel->setCaller(function ($callback) {
//        return app()->call($callback); // laravel 内可以这样实现协程内依赖注入
//    });

    for ($i = 0; $i < 5; ++$i) {
        $parallel->add(function () use ($i) {
            \Swoole\Coroutine::sleep(1);
            return $i;
        });
    }

    $results = $parallel->wait();
    $diff = time() - $time;
    var_dump($results);
    print_r("运行了:{$diff}秒");
});
```

运行结果

```
array(5) {
  [0]=>
  int(0)
  [4]=>
  int(4)
  [3]=>
  int(3)
  [2]=>
  int(2)
  [1]=>
  int(1)
}
运行了:1秒

```

> 请务必在协程环境下使用

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

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

Total

3

Last Release

2158d ago

### Community

Maintainers

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

---

Top Contributors

[![qbhy](https://avatars.githubusercontent.com/u/24204533?v=4)](https://github.com/qbhy "qbhy (9 commits)")

### Embed Badge

![Health badge](/badges/qbhy-swoole-parallel/health.svg)

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

PHPackages © 2026

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