An exciting new feature of Laravel is Laravel Queues that is used to make sleek applications by stacking heavy tasks to be handled as jobs, and dispatching these jobs when it is asked to or when it does not interrupt the user’s experience.
To monitor and analyze this process, Taylor Otwell has recently announced Laravel Horizon an open source dashboard app that keeps track of Laravel Redis queues. The Horizon dashboard is a single page application built using Vue.js. The application is designed to provide real-time insights into queue workloads, recent jobs, failed jobs, job retries, throughput and runtime metrics, and process counts.
According to Taylor Otwell
“I built Horizon to scratch my own itch. I need deep insight into my queue throughput, performance, wait times, failures. And, when a customer has a problem, Horizon allows me to quickly find the job that failed.”
Taylor Otwell – Creator of Laravel
In this article, I will demonstrate how to install Laravel Horizon on Cloudways. Let’s get started.
Pre-Requirements for Laravel Horizon
Before getting into the installation process, there are several requirements for Horizon:
- Laravel 5.5
- Redis (Horizon requires Redis)
- PHP 7.1+ (Horizon uses async process signals)
I will begin by creating a server on Cloudways with a Laravel 5.5 app.
Create the Cloudways Server with Laravel 5.5
To host a Laravel application on Cloudways, sign up for a free trial, login to your account and create a new server. Fill in the server and the application details, and select Laravel 5.5 as your application.
That’s it, you have just installed a new Laravel 5.5 application within a few clicks on the Cloudways platform.
Install Redis on Cloudways
After logging in to your Cloudways account, go to the Servers Tab, click on Setting & Packages. Next, click on Packages. Click the Install button beside Redis. In just a few seconds, Redis will be installed on your server.
Enable PHP 7.1 on the Server
The next step is the selection of the PHP version that supports Laravel Horizon. Click the drop-down menu beside the PHP tab, and change the PHP version to 7.1.
Note: Make sure all your applications on the server are compatible with PHP 7.1
Install Laravel Horizon
To install Laravel Horizon, type the following command in the SSH terminal:
composer require laravel/horizon
After installing Horizon, publish its assets using the vendor:publish Artisan command:
php artisan vendor:publish --provider="Laravel\Horizon\HorizonServiceProvider"
That’s it, Laravel Horizon is installed on your Laravel application on Cloudways. Go to your Application tab and run your application on the provided staging URL.
Now add /horizon to the URL to see the Laravel Horizon dashboard.
Laravel Horizon is a wonderful tool for executing and monitoring Laravel queue workers. You can easily keep it active with the Cloudways Supervised Queue Manager. If you have any query, you could either post a comment below or email me directly.
Saquib is a PHP Community Expert at Cloudways - A Managed PHP Hosting Cloud Platform. He is well versed in PHP and regularly contributes to open source projects. For fun, he enjoys gaming, movies and hanging out with friends. You can email him at firstname.lastname@example.org
Create Laravel apps without the worry of server management.
Deploy your app on optimized PHP hosting servers for Laravel.