Laravel Horizon Clear All

/ About

The Problem

If you've worked with Laravel Horizon, you know the drill. You've got a handful of queues (default, emails, notifications, imports, maybe a few more). During development, you push a batch of test jobs, something breaks, and now you've got hundreds of stale jobs sitting in your queues.

The built-in horizon:clear command only clears one queue at a time:

php artisan horizon:clear --queue=default
php artisan horizon:clear --queue=emails
php artisan horizon:clear --queue=notifications
php artisan horizon:clear --queue=imports

That gets tedious fast, especially when you've got 8+ queues defined in your horizon.php config.

The Solution

This package adds a single command that reads your Horizon configuration and clears every defined queue in one shot:

php artisan horizon:clear-all

That's it. It introspects your horizon.php config, finds every queue across all your supervisors and environments, and clears them all.

Production Safety

Running this in production is intentionally gated. The command checks your environment and prompts for confirmation:

Are you sure you want to clear all queues? (yes/no) [no]:

For CI/CD pipelines or scripted deployments where you actually need to flush queues, the --force flag skips the prompt:

php artisan horizon:clear-all --force

How It Works

The package does three things:

  1. Reads your Horizon config: parses config('horizon') to find all supervisor definitions and their associated queues
  2. Deduplicates: if multiple supervisors reference the same queue, it only clears it once
  3. Calls the native horizon:clear: for each unique queue, it dispatches the built-in clear command so you get the same behavior Horizon already provides, just automated

The implementation is deliberately minimal. There's no custom Redis interaction, no queue driver abstraction. It's a thin wrapper around what Horizon already does well.

Installation

composer require twithers/laravel-horizon-clear-all

Requires PHP 8.2+, Laravel 11+, and Laravel Horizon 5+. The package auto-discovers, no service provider registration needed.