humolot/ci4-bus
Composer 安装命令:
composer require humolot/ci4-bus
包简介
A full-featured asynchronous Job Bus for CodeIgniter 4 (Queue Worker, Failed Jobs, Delays, Retries, PM2/Supervisor-ready).
README 文档
README
A full-featured asynchronous Job Bus and Queue Worker system for CodeIgniter 4 — similar to Laravel Queues & Horizon, but built specifically for CI4.
Now installable via Composer:
composer require humolot/ci4-bus
✨ Features
- 🚀 Dispatch async jobs using
Bus::dispatch() - ⏰ Delayed jobs (
Bus::later()) - 🔁 Automatic retry logic
- ❌ Failed job storage & management
- 🧹 Commands to clear jobs and failed jobs
- 🔄 Retry individual or all failed jobs
- 🛠
bus:maketo scaffold new Job classes - 🧵 Custom worker:
bus:work - 🔧 Configurable (attempts, delay, sleep, restart cycle)
- 🖥️ Compatible with PM2, Supervisor, Systemd, NSSM (Windows)
📦 Installation
composer require humolot/ci4-bus
Run installer:
php spark bus:install
This will create:
app/Jobs/
app/Jobs/JobInterface.php
app/Jobs/BaseJob.php
app/Config/Bus.php
migrations for jobs & failed_jobs
Run migrations:
php spark migrate
⚙ Configuration (app/Config/Bus.php)
class Bus extends BaseConfig
{
public int $maxAttempts = 3;
public int $delaySeconds = 5;
public int $restartAfterJobs = 500;
public int $sleepSeconds = 1;
}
🛠 Creating Jobs
Generate:
php spark bus:make SendEmailJob
Your job:
namespace App\Jobs;
class SendEmailJob extends BaseJob
{
public function handle(array $data)
{
// Your logic here
}
}
🚀 Using the Package (Correct Path via Composer)
Import the Bus class from vendor:
use Humolot\Bus\Bus;
Bus::dispatch(\App\Jobs\SendEmailJob::class, ['id' => 10]);
Dispatch immediately
Bus::dispatch(\App\Jobs\SendEmailJob::class, [
'email' => 'user@example.com'
]);
Dispatch later
Bus::later(60, \App\Jobs\SendEmailJob::class, [
'email' => 'user@example.com'
]);
Bulk dispatch
Bus::bulk([
['class' => JobA::class, 'payload' => [...]],
['class' => JobB::class, 'payload' => [...], 'delay' => 10]
]);
🧵 Running the Worker
php spark bus:work
🔥 Production Worker Setup
PM2
npm install pm2 -g
pm2 start php --name ci4_bus -- spark bus:work
pm2 save
pm2 startup
Supervisor
[program:ci4_bus]
command=/usr/bin/php /var/www/project/spark bus:work
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/var/log/ci4_bus.log
Reload:
supervisorctl reread
supervisorctl update
Windows (NSSM)
nssm install CI4BusWorker
❌ Failed Job Management
php spark bus:failed
php spark bus:failed:retry 12
php spark bus:retry-all
php spark bus:failed:clear
🧹 Clearing Jobs
php spark bus:clear
📁 Folder Structure
Because the package is now installed via Composer, the core lives in:
vendor/humolot/ci4-bus/src
Your application files remain in:
app/Jobs/
app/Config/Bus.php
app/Models/
app/Libraries/Bus.php (auto-published)
📜 License
MIT License.
humolot/ci4-bus 适用场景与选型建议
humolot/ci4-bus 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 11 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「queue」 「async」 「jobs」 「bus」 「horizon」 「codeigniter4」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 humolot/ci4-bus 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 humolot/ci4-bus 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 humolot/ci4-bus 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP AMQP Binding Library
The bundle for easy using json-rpc api on your project
An async event for hyperf.
A Laravel package to monitor queue jobs.
This module enables subscription to latest jobs by email
Super-simple, minimum abstraction Lever DATA API v1 wrapper in PHP with support for Laravel.
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 25
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-11-16