Boost your application with

 Nabeel Ahmed

Hello World

Example

Real

Do calculations and and create report

SMTP

Order
Management
System

Order
Management
System

Queues

Queue-able in Laravel

Mails
Notifications
Jobs
<?php

namespace App\Mail;

use Illuminate\Contracts\Queue\ShouldQueue;

class OrderShipped extends Mailable implements ShouldQueue
{
    //
}


// Send
Mail::to($user)->send(new OrderShipped($order));
<?php

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;

class InvoicePaid extends Notification implements ShouldQueue
{
    use Queueable;

    // ...
}

// Send
$user->notify(new InvoicePaid($invoice));

Laravel Horizon

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

Hands-on Demo

Dashboard Authorization

/**
 * Register the Horizon gate.
 *
 * This gate determines who can access Horizon in non-local environments.
 *
 * @return void
 */
protected function gate()
{
    Gate::define('viewHorizon', function ($user) {
        return in_array($user->email, [
            'taylor@laravel.com',
        ]);
    });
}

Dashboard Authorization

/**
 * Register the Horizon gate.
 *
 * This gate determines who can access Horizon in non-local environments.
 *
 * @return void
 */
protected function gate()
{
    Gate::define('viewHorizon', function ($user) {
        return $user->hasRoleWithPermission('viewHorizon');
    });
}

Metrics

/**
 * Define the application's command schedule.
 *
 * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
 * @return void
 */
protected function schedule(Schedule $schedule)
{
    $schedule->command('horizon:snapshot')->everyFiveMinutes();
}

Dashboard which provides information on your job and queue wait times and throughput.

LongWaitDetected

class HorizonServiceProvider extends HorizonApplicationServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        parent::boot();
        // Horizon::routeSmsNotificationsTo('15556667777');
        Horizon::routeMailNotificationsTo(config('app.admin_email'));
        // Horizon::routeSlackNotificationsTo('slack-webhook-url', '#channel');
    }

Ge notified when any of your queues has a long wait time.

laravel-failed-job-monitor

Get notified when a queued job fails.

return [
    /**
     * The channels to which the notification will be sent.
     */
    'channels' => ['mail', 'slack'],

    'mail' => [
        'to' => 'email@example.com',
    ],

    'slack' => [
        'webhook_url' => env('FAILED_JOB_SLACK_WEBHOOK_URL'),
    ],
];

Dark Mode FTW

Questions?

 Nabeel Ahmed

Resources

Made with Slides.com