igorsgm/illuminate-concurrency
Composer 安装命令:
composer require igorsgm/illuminate-concurrency
包简介
Standalone extraction of Laravel's Illuminate Concurrency component. Run tasks concurrently using process, fork, or sync drivers.
README 文档
README
A standalone extraction of Laravel's Concurrency component for use outside of the full laravel/framework package.
Why does this package exist?
Laravel ships many of its components as standalone illuminate/* packages, allowing developers to use them in non-Laravel projects or micro-frameworks. However, the Concurrency component has not yet been split into its own illuminate/concurrency package — it only lives inside the monolithic laravel/framework repository.
This package extracts the Concurrency component exactly as it exists in laravel/framework, making it installable as a first-class Composer dependency without pulling in the entire framework.
Installation
composer require igorsgm/illuminate-concurrency
Optional: Before using the fork driver, you need to install the spatie/fork package:
composer require spatie/fork
Concurrency (from Laravel Docs)
Introduction
Sometimes you may need to execute several slow tasks which do not depend on one another. In many cases, significant performance improvements can be realized by executing the tasks concurrently. Laravel's Concurrency facade provides a simple, convenient API for executing closures concurrently.
How it Works
Laravel achieves concurrency by serializing the given closures and dispatching them to a hidden Artisan CLI command, which unserializes the closures and invokes it within its own PHP process. After the closure has been invoked, the resulting value is serialized back to the parent process.
The Concurrency facade supports three drivers:
| Driver | Description | Requires |
|---|---|---|
process |
Runs tasks in parallel child processes (default) | — |
fork |
Uses pcntl_fork for true parallel execution. Offers improved performance compared to the default process driver, but it may only be used within PHP's CLI context, as PHP does not support forking during web requests. |
spatie/fork, CLI only |
sync |
Primarily useful during testing when you want to disable all concurrency and simply execute the given closures in sequence within the parent process. | — |
Running Concurrent Tasks
To run concurrent tasks, you may invoke the Concurrency facade's run method. The run method accepts an array of closures which should be executed simultaneously in child PHP processes:
use Illuminate\Support\Facades\Concurrency; use Illuminate\Support\Facades\DB; [$userCount, $orderCount] = Concurrency::run([ fn () => DB::table('users')->count(), fn () => DB::table('orders')->count(), ]);
To use a specific driver, you may use the driver method:
$results = Concurrency::driver('fork')->run(...);
Or, to change the default concurrency driver, you should publish the concurrency configuration file via the config:publish Artisan command and update the default option within the file:
php artisan config:publish concurrency
Deferring Concurrent Tasks
If you would like to execute an array of closures concurrently, but are not interested in the results returned by those closures, you should consider using the defer method. When the defer method is invoked, the given closures are not executed immediately. Instead, Laravel will execute the closures concurrently after the HTTP response has been sent to the user:
use App\Services\Metrics; use Illuminate\Support\Facades\Concurrency; Concurrency::defer([ fn () => Metrics::report('users'), fn () => Metrics::report('orders'), ]);
Source
This package mirrors the source code from:
License
The MIT License (MIT). See LICENSE.md for details.
igorsgm/illuminate-concurrency 适用场景与选型建议
igorsgm/illuminate-concurrency 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 35 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「process」 「fork」 「async」 「laravel」 「parallel」 「illuminate」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 igorsgm/illuminate-concurrency 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 igorsgm/illuminate-concurrency 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 igorsgm/illuminate-concurrency 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Doctrine implementation of the MetaborStd (Statemachine) for PHP 8.2+
PHP Trello API Wrapper (fork for php7+) from https://github.com/ashwinks/Trello-API-PHP-Wrapper
Shell command module for PHP.
The bundle for easy using json-rpc api on your project
An async event for hyperf.
A fluent PHP library for supervised master-child process control using pcntl and pipes
统计信息
- 总下载量: 35
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 39
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-05