- How do I convert a Laravel event into a series of queued jobs using JobPipeline?
- Use `JobPipeline::make([Job1::class, Job2::class])->send(function($event) { return $event->data; })->shouldBeQueued(true)`. This registers the pipeline as an event listener and queues all jobs sequentially. The `send()` method extracts data from the event to pass to the jobs.
- Does JobPipeline work with Laravel 11/12/13, or only older versions?
- JobPipeline is fully compatible with Laravel 10+, including 11, 12, and 13. The package is regularly updated to align with Laravel’s latest features, such as queue batching in Laravel 10+. Check the [GitHub repo](https://github.com/archtechx/jobpipeline) for version-specific notes.
- Can I run a pipeline synchronously or asynchronously? How do I control this?
- By default, pipelines run synchronously. To queue them, call `->shouldBeQueued(true)`. For global defaults, set `JobPipeline::$shouldBeQueuedByDefault = true` in a service provider. You can also specify a custom queue name, e.g., `->shouldBeQueued(true, 'high-priority')`.
- What happens if one job in the pipeline fails? Can I retry or skip failed jobs?
- By default, the pipeline stops at the first failed job. To retry, wrap jobs in `try-catch` blocks or use Laravel’s failed job system (`config('queue.fail_on_timeout')`). For conditional logic, return `false` from a job to cancel the pipeline. For retries, pair with `spatie/laravel-queue-supervisor` or implement custom retry logic.
- How do I pass dynamic data from an event to jobs in the pipeline?
- Use the `send()` method to map event data to jobs. For example, `->send(function($event) { return $event->tenant; })` passes the `tenant` property to all jobs. You can also use closures to transform data, like `->send(fn($event) => ['id' => $event->tenant->id, 'name' => $event->tenant->name])`.
- Is JobPipeline compatible with all Laravel queue drivers (Redis, SQS, database)?
- Yes, JobPipeline leverages Laravel’s native queue system, so it works with any supported driver: database, Redis, SQS, or third-party drivers. No additional configuration is needed—just ensure your queue worker is running. For high-throughput systems, monitor queue backlogs with Laravel Horizon or Blackfire.
- How do I test a JobPipeline in Laravel’s testing environment?
- Use Laravel’s `fake()` to mock events and queues. For example: `$this->fake()->events(); $this->fake()->queues();`. Test individual jobs with unit tests, then verify pipeline behavior with integration tests. Mock the `JobPipeline` class if needed, but focus on testing the event dispatch and queue interactions.
- Can JobPipeline handle conditional or branching logic (e.g., skip a job based on data)?
- JobPipeline supports linear sequences by default. For branching logic, dispatch intermediate events between jobs (e.g., `JobA` dispatches `EventX`, which triggers `JobB`). Alternatively, use closures in `send()` to filter data before passing it to jobs. For complex workflows, consider Temporal or custom event dispatching.
- What’s the best way to monitor or debug a JobPipeline in production?
- Use Laravel Telescope to log pipeline execution, or integrate with monitoring tools like Prometheus. For queue visibility, use Laravel Horizon. Add custom logging in jobs (e.g., `Log::info('Job executed')`) or extend the pipeline with middleware. Failed jobs are stored in the `failed_jobs` table by default.
- Are there alternatives to JobPipeline for chaining Laravel jobs? What should I choose?
- Alternatives include custom event listeners with manual job dispatching, packages like `spatie/laravel-job-queue` (for simpler workflows), or orchestration tools like Temporal for complex stateful workflows. JobPipeline is ideal for linear, event-driven sequences with minimal setup. Choose it if you want Laravel-native, queue-agnostic, and SOLID-compliant job chaining.