Upsun User Documentation

Handle queues with Horizon

Try Upsun for 15 days
After that, enjoy the same, game-changing Upsun features for less with the First Project Incentive!ยน A monthly $19 perk!
ยนTerms and conditions apply
Activate your 15-day trial

Laravel Horizon provides an appealing dashboard and code-driven configuration for your Laravel powered Redis queues. Horizon allows you to monitor key metrics of your queue system, such as job throughput, runtime, and job failures.

1. Add Laravel Horizon Anchor to this heading

  1. To add Laravel Horizon, run the following command:

    Terminal
    composer require laravel/horizon && php artisan horizon:install
  2. Add the install command to your build hook in your app configuration, so it’s run on every deploy.

    .upsun/config.yaml
    applications:
        myapp:
            [...]
            hooks:
                build: |
                        set -eux
                        composer --no-ansi --no-interaction install --no-progress --prefer-dist --optimize-autoloader --no-dev
                        php artisan horizon:install                    

2. Create a worker to run Horizon Anchor to this heading

To run Horizon on your project, you need to add a separate worker. To do so, use the following configuration:

.upsun/config.yaml
applications:
    [...]
        APP_NAME:
            [...]
            workers:
                horizon:
                    commands:
                        start: |
                            php artisan horizon                            

To enable the worker, push your changes to Upsun:

Terminal
git add .
git commit -m "Enable Laravel Horizon"
upsun push

A new container is started automatically. It will spawn the Horizon process after the next deploy.

3. Access your Horizon dashboard Anchor to this heading

If you have restricted access to Horizon in your HorizonServiceProvider.php, log in to your app through the web. Then, go to /horizon to access your Horizon dashboard.

Laravel Horizon Dashboard

4. Optional: Customize Horizon Anchor to this heading

Horizon handles jobs that are populated by the queue. If you need to customize how Horizon works (queues, processes, etc.), see the official Laravel Horizon documentation.

Note that you can customize the resources of your Horizon worker container from the Upsun Console.

Laravel Horizon Resources

For more information, see how to configure resources.

Is this page helpful?