A demo for Laravel Horizon, a Redis queue monitor. Announced at Laracon US 2017.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
app
bootstrap
config
database
public
resources
routes
storage
tests
.env.example
.gitattributes
.gitignore
README.md
artisan
composer.json
composer.lock
package.json
phpunit.xml
server.php
webpack.mix.js

README.md

Laravel Horizon Demo

laravel-horizon

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

  1. Clone this project.

  2. Run php composer install.

  3. Sign up for a free Mailtrap account and copy API credentials. We'll use Mailtrap to spoof outgoing emails using their demo inbox:

    Mailtrap demo inbox

  4. Enter values for these directives on your .env file:

  • APP_KEY → Run php 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.
  1. Run php artisan config:cache to use the values set above.

  2. Create a blank database.sqlite under your ./database directory.

  3. Run php artisan migrate --seed to create a user table and seed it with dummy user information (e.g. name, email).

  4. Run composer dump-autoload to clear the PHP class cache.

  5. 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.

  6. Open a new shell prompt and run php artisan horizon on the foreground and view the Horizon dashboard at http://[app-host]/horizon.

    horizon-cli

  7. 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.

    fetch-star-wars-entity-url

    fetch-star-wars-entity-result

    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.

    two-jobs

    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.