A lightweight (low-budget), queue system for PHP applications.
- Because I can.
- I was working on some vanilla php projects and sometimes needed to create cron jobs for each operation I wanted to run in the background. But I'd have to create a dedicated file to run the job, add a new entry in crontab.....
Checkout other projects under logadapp 😊
composer require
Create a job by extending the base Job
class:
<?php
namespace App\Jobs;
use LogadApp\Queue\Job;
class SendEmailJob extends Job
{
public function __construct(
private readonly string $recipient,
private readonly string $subject,
private readonly string $content
) {}
protected function handle(): void
{
// Email sending logic here
}
}
<?php
use App\Jobs\SendEmailJob;
// Dispatch a job to the default queue
SendEmailJob::dispatch(
'[email protected]',
'Welcome!',
'Thanks for signing up.'
));
// extra parenthesis because 8.5 is not out yet
(new SendEmailJob(
recipient: "explicit-{$i}@test.com",
subject: "Explicit {$i}",
content: "HII"
))->dispatchSelf();
Run the worker command to process jobs:
php bin/console queue:work
- Database storage support
- Failed job handling