- How do I make a Laravel job runnable via Artisan *and* the queue?
- Extend your job with `ShouldQueue` and implement the `ArtisanDispatchable` interface. Then run it via `php artisan job-name` or schedule it with `$schedule->job(new YourJob)`. No extra configuration is needed.
- Will this work with Laravel 10+? Any breaking changes?
- Yes, it’s fully compatible with Laravel 10+. The package follows Laravel’s native job system, so no breaking changes are expected unless Laravel’s queue or Artisan APIs change.
- Can I test jobs dispatched via Artisan in PHPUnit?
- Yes. Use `Artisan::call('job-name')` in tests to simulate CLI execution. For queue behavior, test with Laravel’s standard queue testing helpers like `Queue::fake()`.
- What happens if I dispatch a job via Artisan but it fails? Will it retry?
- No. Artisan dispatches bypass the queue system, so retries won’t trigger. Use `ShouldQueue` consistently for retries or wrap Artisan calls in error handling.
- Does this package support Redis/SQS queues?
- Yes. It relies on Laravel’s built-in queue system, so Redis, SQS, or database drivers work out of the box. No extra setup is required for queue backends.
- How do I monitor jobs dispatched via Artisan in Horizon?
- Horizon won’t track Artisan-dispatched jobs by default. Use logging (e.g., `Log::info()` in your job) or a custom monitoring solution to track CLI executions separately.
- Is there a way to limit concurrency for Artisan-dispatched jobs?
- No. Artisan commands run sequentially, so concurrency isn’t controlled by this package. For parallelism, dispatch jobs via the queue instead or use Laravel’s `dispatchSync()` carefully.
- Can I use this for one-off CLI tasks that don’t need queuing?
- Yes. It’s ideal for hybrid workflows—use Artisan for immediate execution (e.g., `php artisan process-backup`) while still allowing queued scheduling for production.
- What’s the performance impact of dispatching jobs via Artisan vs. queue?
- Artisan dispatches are synchronous and block the CLI process, while queue jobs run asynchronously. For long tasks (>1 min), prefer queueing to avoid scheduler delays.
- Are there alternatives to this package for Artisan + queue jobs?
- No direct alternatives exist, but you could manually dispatch jobs via `Artisan::queue()` or use Laravel’s `dispatch()` in commands. This package provides a cleaner, standardized approach.