laravel-horizon-demo
laravel-horizon-demo copied to clipboard
A demo for Laravel Horizon, a Redis queue monitor. Announced at Laracon US 2017.
Laravel Horizon Demo
Laravel Horizon provides an easy-to-use, interactive GUI to monitor and interact with Redis queues.
Horizon was announced at Laracon US 2017 in NYC. It requires Laravel 5.5 to run (which is currently in beta).
Quick start
-
Clone this project.
-
Run
php composer install
. -
Sign up for a free Mailtrap account and copy API credentials. We'll use Mailtrap to spoof outgoing emails using their demo inbox:
-
Enter values for these directives on your
.env
file:
-
APP_KEY
→ Runphp artisan key:generate
to easily generate a base64-encoded key. -
MAIL_*
→ Enter Mailtrap credentials. -
REDIS_*
→ A standard Redis installation usually does not require you to change values.
-
Run
php artisan config:cache
to use the values set above. -
Create a blank
database.sqlite
under your./database
directory. -
Run
php artisan migrate --seed
to create a user table and seed it with dummy user information (e.g. name, email). -
Run
composer dump-autoload
to clear the PHP class cache. -
Open a new shell prompt and run
php artisan serve
to serve the web application on the foreground using PHP's built in web server.Note: On macOS, it's easier to use Laravel Valet.
-
Open a new shell prompt and run
php artisan horizon
on the foreground and view the Horizon dashboard athttp://[app-host]/horizon
. -
By visiting
http://[app-host]/queues/fetch-star-wars-entity?repeat=1&user_id=1
, you can now test Horizon by creating a job that fetches a random Star Wars entity from the unofficial Star Wars public API and subsequently sends a notification email.Two async jobs are actually dispatched when you hit the URL above: (a) one that fetches from the Star Wars API and (b) another one that sends a notification email.
Note: You can increase the number of requests sent (and conversely, resulting email notifications) by increasing the
repeat
query parameter to a higher number -- say, for example, 100. Just be aware that if using a service other than Mailtrap's demo inbox, you might get flagged for sending spam.
Requirements
- PHP v7.1
- Redis v3.x
Attributions
This wouldn't be possible without being granted a role as Software Developer at Pixel Fusion, an award-winning product development company at Parnell, Auckland.