Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Pipeline Laravel Package

illuminate/pipeline

Illuminate Pipeline provides a simple, fluent way to send an object through a series of pipes (closures or classes) in Laravel. Build customizable middleware-style workflows, transform data step by step, and control the final destination with clean, composable code.

View on GitHub
Deep Wiki
Context7

Getting Started

Start by requiring the package: composer require illuminate/pipeline. If you're in a Laravel app, it's already included—no extra setup needed. For standalone projects, bootstrap a simple pipeline with send($value)->through([...pipes])->thenReturn(). A first use case: chain validation and normalization steps for incoming API data—e.g., cast types, validate required fields, and transform dates—without bloating controllers.

Implementation Patterns

  • Middleware-style processing: Replace ad-hoc conditionals with pipes for cross-cutting concerns (auth, logging, rate limiting). Each pipe accepts the payload, modifies it, and returns it—or short-circuits by not calling $next($payload).
  • Domain workflows: Model complex processes (e.g., order fulfillment) as a pipeline: ApplyDiscount → ValidateStock → ReserveInventory → SendConfirmation. Pipes stay small, testable, and composable.
  • Container-based pipes: Use send($payload)->through(['App\Pipes\ValidateEmail', ValidatePhone::class])->resolveUsing(app())→thenReturn(). Ideal when pipes depend on services (e.g., repositories, mailers).
  • Reusability: Build generic pipelines (e.g., ValidationPipeline, AuditPipeline) and parametrize them—e.g., inject rules or callbacks—to reuse across handlers, jobs, and console commands.
  • Custom endpoints: Override then() to run final aggregation logic (e.g., summarizing pipeline results), or use pipe() to return the instance for deferred execution.

Gotchas and Tips

  • Silent failures: If a pipe omits return $payload, the next stage receives null. Always explicitly return the payload—even if unmodified—to avoid subtle bugs.
  • Mutable state leaks: Pipelines mutate shared objects in-place. Clone payloads (clone $order) when idempotency matters (e.g., retries, dry-runs).
  • Exception handling: Uncaught exceptions halt the chain. Wrap thenReturn() in try/catch, or add a final pipe that logs errors and returns a fallback.
  • Testability: Avoid closures in production pipelines—use invokable classes or explicit handle($payload, callable $next) methods for easy mocking and assertion.
  • Order optimization: Place cheap, high-impact filters first (e.g., isAuthenticated, isValidInput) before expensive operations (DB queries, external API calls).
  • Extensibility hooks: Extend Pipeline to inject tracing (e.g., timings per pipe), circuit breakers, or context-aware fallbacks—override handlePipe() to intercept pipe execution.
  • Debugging: Use ->pipe(fn ($payload) => dump("Step X: ", $payload)) sparingly; better yet, log payload snapshots with context via a dedicated debug pipe.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport