定制 mr-rijal/laravel-pipeline 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mr-rijal/laravel-pipeline

Composer 安装命令:

composer require mr-rijal/laravel-pipeline

包简介

Lightweight workflow and automation pipeline for Laravel

README 文档

README

Workflow Latest Version PHP Latest Stable Version License Downloads Star

Lightweight, enterprise-ready pipeline workflow engine for Laravel Supports sequential, parallel, and flow-based execution with debug timeline, retries, timeouts, and queued parallelism.

📦 Installation

Install via Composer:

composer require mr-rijal/laravel-pipeline

Laravel auto-discovers the service provider. No manual registration required.

🛠️ Features

  • Sequential, parallel, and flow pipelines
  • Debug timeline with per-step execution metrics
  • Retry failed steps with configurable attempts
  • Step timeout support
  • Parallel execution with optional queue (Redis/Horizon)
  • Shared LaravelPipelineContext for passing data between steps
  • Works with Closures or classes implementing handle(LaravelPipelineContext $ctx)
  • PHPUnit + Testbench ready
  • Lightweight, production-grade performance

🔧 Usage

1️⃣ Basic Sequential Steps

use MrRijal\LaravelPipeline\Facades\LaravelPipeline;
use MrRijal\LaravelPipeline\DTO\LaravelPipelineContext;

LaravelPipeline::steps([
    fn (LaravelPipelineContext $ctx) => $ctx->set('foo', 'bar'),
    fn (LaravelPipelineContext $ctx) => $ctx->get('foo'), // returns 'bar'
])->run();

2️⃣ Flow (Continue on Fail)

$results = LaravelPipeline::flow([
    fn() => true,
    fn() => false, // continue even if fails
    fn() => true
]);

3️⃣ Parallel (Run All at Once)

$results = LaravelPipeline::parallel([
    StepOne::class,
    StepTwo::class,
]);

🧰 Advanced Features

Debug Timeline

$pipeline = LaravelPipeline::steps([
    StepOne::class,
    StepTwo::class,
])->with(['user_id' => 5]);

$pipeline->run(); // or wrap in try/catch if steps may throw
$results = $pipeline->getResults();

foreach ($results as $step) {
    echo "{$step->name}: " . ($step->success ? '' : '') . " ({$step->time}ms)\n";
}

Output Example:

StepOne: ✔ (0.12ms)
StepTwo: ✘ (0.21ms) - Exception message if failed

Retry & Timeout

Retry and timeout are currently supported via the runStep() method when building custom pipelines; a more convenient array format [Step::class, 'retry' => 3, 'timeout' => 500] is planned for a future release. See docs for details.

Queued Parallel Execution

LaravelPipeline::parallel([
    StepOne::class,
    StepTwo::class
], queue: true); // Dispatches steps to Laravel queue
  • Works with Laravel Redis queues or Horizon
  • Steps executed concurrently without blocking main thread

Shared Pipeline Context

LaravelPipelineContext allows passing data between steps:

LaravelPipeline::steps([
    fn (LaravelPipelineContext $ctx) => $ctx->set('user_id', 123),
    fn (LaravelPipelineContext $ctx) => $ctx->get('user_id'), // 123
])->run();

⚡ Benchmark

vendor/bin/phpunit --filter BenchmarkTest

Typical performance (3-step pipeline):

  • Sequential: < 10ms (micro-benchmark)
  • Memory usage: negligible
  • Parallel queued execution depends on queue worker speed

💡 Step Types

  1. Closure
fn (LaravelPipelineContext $ctx) => true
  1. Class with handle() (class name or instance)
class StepOne
{
    public function handle(LaravelPipelineContext $ctx): bool
    {
        return true;
    }
}
  1. Boolean literal
true // simple pass/fail (e.g. in flow())

🔧 Testing

Run PHPUnit tests:

vendor/bin/phpunit

Includes:

  • Sequential / flow / parallel tests
  • Micro-benchmark tests

📝 Notes

  • Make sure queue workers are running when using parallel(queue: true)
  • Use getResults() for detailed debugging or logging
  • Step names are auto-detected from class name or “Closure”

💖 Sponsor

If you find this project helpful, please consider sponsoring my open source work to help sustain development and maintenance!

Thank you for supporting open source software.

🔖 License

MIT © Prashant Rijal

mr-rijal/laravel-pipeline 适用场景与选型建议

mr-rijal/laravel-pipeline 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 18 次下载、GitHub Stars 达 2, 最近一次更新时间为 2026 年 01 月 24 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「php」 「workflow」 「laravel」 「automation」 「event-driven」 「state-machine」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 mr-rijal/laravel-pipeline 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 mr-rijal/laravel-pipeline 我们能提供哪些服务?
定制开发 / 二次开发

基于 mr-rijal/laravel-pipeline 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 18
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 36
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-24