- How do I install Laravel Horizon for Redis queue monitoring?
- Run `composer require laravel/horizon` and then `php artisan horizon:install`. This sets up the dashboard and publishes the default configuration file (`config/horizon.php`). For customization, use `php artisan horizon:publish` instead.
- Does Laravel Horizon work with Laravel 10 and PHP 8.5?
- Yes, Horizon officially supports Laravel 10+ (v5.44.0+) and is backward-compatible with PHP 8.5 (since v5.40.1). Always check the [Laravel docs](https://laravel.com/docs/horizon) for the latest version compatibility.
- Can I use Horizon with non-Redis queues like database or SQS?
- No, Horizon is designed exclusively for Redis queues. If you rely on database queues (e.g., `database` or `beanstalkd`), you’ll need to migrate to Redis first or use alternative tools like `laravel-queue-worker-monitor` for other backends.
- How do I configure multiple worker supervisors (e.g., for different queue priorities)?
- Edit `config/horizon.php` and define multiple `supervisors` under the `supervisors` key. Each can specify unique `connection`, `queue`, `balance`, and `processes` settings. For example, separate supervisors for `high`, `default`, and `failed` queues.
- What metrics does the Horizon dashboard show, and how can I customize them?
- The dashboard displays job throughput, runtime, failures, and retry counts. Customize metrics by extending Horizon’s `HorizonServiceProvider` or overriding views in `resources/views/vendor/horizon`. For advanced metrics, use Laravel’s `Horizon::metrics()` method.
- How do I migrate from `queue:work` or Supervisor to Horizon?
- Replace `queue:work` with `horizon:work` or `horizon:listen` for long-running supervision. If using Supervisor, update your config to manage Horizon’s processes (e.g., `horizon:work` as a command). Test in staging first to ensure job throughput isn’t disrupted.
- Why does Horizon require Redis, and how do I check if my app is ready?
- Horizon uses Redis for real-time job monitoring and supervision. Verify readiness by running `php artisan queue:failed-table` (to check current failures) and benchmarking Redis performance under load. Horizon won’t work without Redis.
- How do I handle job failures or timeouts in Horizon?
- Failed jobs appear in the dashboard under the “Failed” tab. Retry them manually or configure automatic retries in `config/horizon.php` under `failed_jobs`. For timeouts, adjust `max_runtime` per supervisor or job class.
- Can I integrate Horizon with existing Laravel jobs or middleware?
- Yes, Horizon inherits all existing Laravel queue configurations, including middleware and job classes. No changes are needed for standard jobs. For custom logic, use Horizon’s `Horizon::metrics()` or extend the `JobProcessor` class.
- What’s the best way to deploy Horizon in production, and how do I monitor its health?
- Deploy Horizon alongside your Laravel app, ensuring Redis is accessible. Monitor health via the dashboard’s “Workers” tab or CLI (`php artisan horizon:terminate`). Use Supervisor to manage Horizon’s processes if needed, but Horizon replaces manual `queue:work` supervision.