<aside> 📌 Follow these steps to use Laravel Horizon for Job Queueing in Statamic when hosted with Forge. This guide assumes that redis is already installed via Forge.

</aside>

  1. Add horizon to the project composer require laravel/horizon and publish its assets php artisan horizon:install

  2. Allow Statamic/Laravel user to authenticate for Horizon by adding their accounts email(s) to the HorizonServiceProvider.php

    Untitled

  3. Make sure the environment horizon should run on is configured properly in config/horizon.php.

  4. Add a new Daemon to run php artisan horizon (This will make sure the horizon command is always run and will restart it if it fails unexpectedly)

    Untitled

  5. The active daemon looks like this:

    Untitled

  6. Add php artisan horizon:terminate to the end of the deploy script. This will make sure the old Horizon workers are gracefully terminated on each deployment, and fresh Horizon workers will be started thanks to our daemon configuration

  7. Tell [[Statamic]] to use redis as the queue connection via .env: QUEUE_CONNECTION=redis

  8. Configure the redis connection in config/queue.php

Test if it works

You can test by enabling Git integration with dispatch

STATAMIC_GIT_ENABLED=true
STATAMIC_GIT_PUSH=true
STATAMIC_GIT_DISPATCH_DELAY=10
STATAMIC_GIT_AUTOMATIC=true

Clear the config cache, log into Statamic CP, make some content changes and open the Horizon Dashboard (you'll have access as soon as you're logged in with a user that has been added to 'HorizonServiceProvider.php').

There's even a convenient link in the Statamic panel:

CleanShot 2022-02-11 at 13.53.45@2x.png


Avoid conflicts with multiple sites on the same server