---
title: 'Laravel Horizon Setup'
source: 'https://youtube.com/watch?v=2l3kRZb3z4o'
video_id: '2l3kRZb3z4o'
date: 2026-07-28
duration_sec: 274
---

# Laravel Horizon Setup

> Source: [Laravel Horizon Setup](https://youtube.com/watch?v=2l3kRZb3z4o)

## Summary

This tutorial demonstrates how to set up Laravel Horizon in a Docker environment using a pre-made template. The process involves modifying the Docker Compose file, installing the PCNTL extension, installing Horizon via Composer, and configuring it to monitor queues. The video also shows how to create a test job and verify that Horizon is working correctly through its dashboard.

### Key Points

- **Introduction and Template** [0:00] — The presenter introduces a Docker template with Laravel, queue worker, Nginx, database, and Redis, which simplifies the Horizon setup.
- **Modify Docker Compose** [0:30] — Rename the queue worker service to 'horizon' and change the start command from 'queue:work' to 'horizon'.
- **Install PCNTL Extension** [0:47] — Add the PCNTL PHP extension to the Dockerfile, as it is required by Horizon.
- **Install Horizon via Composer** [1:02] — Run 'composer require laravel/horizon' inside the backend directory, then 'php artisan horizon:install' to publish configuration and assets.
- **Horizon Configuration** [1:32] — The config/horizon.php file allows setting supervisors, processes, memory limits, queue balancing strategies, etc.
- **Create a Test Job** [1:54] — Create a ProcessPodcast job that logs output, and add a route to dispatch the job.
- **Environment Variables** [2:32] — Ensure .env has correct Redis host, password, and port (use service name for Docker, localhost for local).
- **Build and Run Containers** [2:53] — Run 'docker compose up --build -d' to build and start containers.
- **Access Horizon Dashboard** [3:00] — Visit /horizon to see the dashboard showing active processes, metrics, batches, pending and completed jobs.
- **Test the Queue** [3:18] — Hit the route multiple times to dispatch jobs; verify they appear as completed in the dashboard.

### Conclusion

Setting up Laravel Horizon in Docker is straightforward: modify the Docker Compose file, install PCNTL and Horizon, configure the service, and use the dashboard to monitor queues. The presenter encourages viewers to like the video to help others avoid overpriced templates.

## Transcript

right so I'm going to show you how to
use Horizon today we're going to deploy
it in our doer environment and it's
going to be really simple I'm using this
template here and it's my own template
that I made from one of the previous
videos I'll put a link in the
description you can just clone it and
continue to work from there the template
already has the laravel app it has a q
worker it has ngx database and Redd is
ready so it's going to be fairly simple
to use I recommend that you start from
this template but if you have your own
Docker compose file you can just use
that so let's get started here the first
thing that we have to replace here is
the Q worker so instead of naming it Q
worker we have to name this service
Horizon and we're going to change the
start command from Q work to Horizon so
this is the only thing required to be
changed in the dock compose yl file we
have to run Horizon with this command
next thing that we have to do is go to
our Docker file and we have to install
pcnl as our dependency so we're going to
be adding pcnl this is used by Horizon
and that's why we're installing it now
we're done with the docker file and
we're done with Docker composed. yaml we
have to install Horizon so you're going
to go to LL you're going to go to the
latest version and you're going to
install Horizon with composer so I'm
going to open my terminal I'm going to
CD into the backend directory so you
should be careful to not install it here
in the root you should install it in the
back end and you copy this command we
install Horizon and then once this is
install we just have to run PHP artison
Horizon install the scaffolding is done
and you should see new files in your
project here we have the horizon. PHP
file and this gives you the config for
Horizon you should read this
documentation up I'm not going to be
doing a tutorial on this but essentially
you have the supervisors and you can say
how many processes there are the memory
how many jobs cues and so on balancing
in these strategies and so on so you
have this file here and we're mostly set
up so let's add a test job here and I'm
going to add a process click job and
this is going to be a really simple job
we're just going to go to the process
click here and we're going to add a log
so we want to see the output and we want
to see if this works and we're going to
import this from the support log here
and there you go so we have this process
click job and now we want to go to our
routes web and let's add a process click
job so for example we can go to our a
URL and it's going to be adding a job to
the queue and returning a response Json
so once we set everything up here we
check our EnV our EnV should have PHP
redus the redus host the redus password
and the red is Port again when you're
running this from a Docker environment
you're going to be adding the service
name but when you're running this
locally you should be adding this local
host address so if we have everything
set up here we can just say Docker
compose up build detach and wait for the
containers to finish building so now
that the containers have been built
let's go to our Local Host here so I'm
going to go to Local Host we have the
laravel let's go to
Horizon and we have the Horizon
dashboard that's it here you go total
process is one it's active we have
monitoring metrics batches pending jobs
completed jobs and let's just test it
out so we have the click route so if we
go here we returned true so it should
run two jobs right now so if I reload
there you go total processes Jobs pass
to so if I go to completed jobs you see
process click job Q default it gives you
the data and let's just let's just run
as many jobs as I can so I'm going to go
here and I'm I'm going to press controlr
here to reload as many times as I can
and if I now go back to Horizon go to
the dashboard you see jav's passed hour
35 everything's working status is active
there if there are any fail jobs it will
show you here you have batches metrics
and you have in metrics here I love this
that it shows you which queue you can
select by which queue the jobs have been
done and the actual job so you can
process click and you can see the data
of course you don't have the throughput
and runtime because I started this like
two minutes ago but the more data you
have you'll have metrics here and this
is how you can host Horizon it's very
simple please leave a like so that other
people see this so that they don't get
scammed for paying templates that are
$100 please like this so people can see
it and I think this is beautiful Horizon
is is a really powerful tool and you
should use it use it in many many
projects
