1. Go to this page and download the library: Download nsumbadze/horizonflow 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/ */
nsumbadze / horizonflow example snippets
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Queue\InteractsWithQueue;
use Laravel\Horizon\Concerns\InteractsWithCancellation;
class SendCampaignMail implements ShouldQueue
{
use InteractsWithQueue;
use InteractsWithCancellation;
public function handle(): void
{
foreach ($this->recipients as $recipient) {
if ($this->cancelIfRequested()) {
return;
}
$this->sendTo($recipient);
}
}
}
use Laravel\Horizon\Concerns\InteractsWithCancellation;
final class FetchCitrusPageJob implements ShouldQueue
{
use InteractsWithCancellation;
public function __construct(
public readonly int $companyId,
public readonly int $page = 1,
) {
}
public function cancellationGroup(): ?string
{
return "citrus-sync:{$this->companyId}";
}
public function handle(): void
{
foreach ($this->pageOfProducts() as $product) {
if ($this->cancelIfRequested()) {
return;
}
$this->process($product);
}
self::dispatch($this->companyId, $this->page + 1);
}
}