PHP code example of donparapidos / horizon

1. Go to this page and download the library: Download donparapidos/horizon library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

donparapidos / horizon example snippets


'providers' => [

    // ..

    Donparapidos\Horizon\HorizonServiceProvider::class,
],
'aliases' => [

    // ..

    "Horizon" => Donparapidos\Horizon\Horizon::class,
]



namespace App\Providers;

// ..

use Donparapidos\Horizon\Horizon;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        // ..

        // Add Horizon authentication [IGNORE IN DEV]
        
        Horizon::auth(function ($request) {
        
            // allow admins  only to see this page 
            // return \Auth::user()->is_admin;
            // or return any true / false
        });
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}

bash

php artisan vendor:publish