1. Go to this page and download the library: Download italix/jobs 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/ */
italix / jobs example snippets
final class SendInvoiceMail implements Job
{
private int $invoice_id;
public function __construct(int $invoice_id) { $this->invoice_id = $invoice_id; }
public static function name_code(): string { return 'invoice.mail'; }
public function payload(): array { return ['invoice_id' => $this->invoice_id]; }
public static function from_payload(array $payload): Job
{
return new self((int) $payload['invoice_id']);
}
public function run(ContainerInterface $services): void
{
$services->get(Mailer::class)->send_invoice($this->invoice_id);
}
}
$queue->push(new SendInvoiceMail($invoice_id));
$queue->push(new BuildReport($id), '+5 minutes');
$queue->push(new Reconcile(), null, 'reconcile:' . date('Y-m-d')); // once a day, whoever asks
Schedule::class => static fn(): Schedule => (new Schedule())
->daily_at('03:30', new PurgeExpiredTokens())
->every_minutes(5, new RetryFailedMail())
->cron('0 9 * * 1-5', new WeekdayDigest()),