1. Go to this page and download the library: Download fof/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/ */
fof / horizon example snippets
use FoF\Redis\Extend\Redis;
return [
// Basic Redis configuration
new Redis([
'host' => '127.0.0.1',
'password' => null,
'port' => 6379,
'database' => 0,
]),
// ... other extenders
];
// extend.php
(new FoF\Horizon\Extend\Horizon)->emailConcurrency(4),
'horizon' => [
'supervisors' => [
// Give the realtime tier more workers than the default.
'realtime' => [
'processes' => 3,
],
// A heavy tier for bulk work.
'long' => [
'queues' => ['exports', 'gdpr'],
],
],
'memory_limit' => 256,
],
use FoF\Horizon\Extend\Horizon;
return [
(new Horizon)
// Route a job onto a queue. This sets the job's queue AND registers it
// so the dashboard and per-queue pause know about it. If the job class
// isn't installed it's skipped, so optional dependencies are safe.
//
// Pass a third argument to also attach that queue to a supervisor in one
// go — e.g. put a translation job's queue on the always-on `standard`
// pool. Without it, the job is routed but no worker consumes the queue
// until a supervisor serves it.
->routeJob(\Your\Extension\Jobs\TranslateJob::class, 'translate', 'standard')
->routeJob(\Your\Extension\Jobs\RealtimeJob::class, 'realtime')
// Routing an abstract base (or interface) covers every job that extends
// (or implements) it — route the base once and all its concrete
// subclasses inherit the queue. A more specific route on a subclass
// still wins over the base.
->routeJob(\Your\Extension\Jobs\AbstractExportJob::class, 'long')
// Add extra queues under an existing profile without touching its other
// settings — handy for base images layering their own queues on.
->queueOn('long', 'exports', 'gdpr')
// Override a profile's knobs. Recognised keys map onto the profile;
// anything else (nice, balanceMaxShift, retry_after, …) passes straight
// through to Horizon.
->supervisor('realtime', ['processes' => 12])
// Define a brand-new profile.
->supervisor('media', ['queues' => ['thumbnails'], 'timeout' => 300, 'processes' => 2]),
];
return [
// Put three extra queues on the `long` profile alongside whatever it
// already serves. Repeated/duplicate names are de-duplicated.
(new FoF\Horizon\Extend\Horizon)
->queueOn('long', 'exports', 'gdpr', 'migration'),
];
'horizon' => [
'supervisors' => [
'standard' => [
'maxJobs' => 1000, // restart the worker after X jobs
'maxTime' => 3600, // restart the worker after X seconds
],
],
],