A minimal job queue library written in PHP that persists data with SQLite.
Use it for small projects / prototypes with at most hundreds or thousands of jobs.
composer require mgleis/php-sqlite-job-queue
$queue = new Queue('queue.sqlite');
$queue->push("a string");
$queue->push(["an" => "array"]);
$queue->push([0, 1, 2, 3, 4]);
$queue->push(['type' => 'SendEmail', 'to' => '...']);
$worker = new Worker($queue);
$worker->process(function(Job $job) {
$payload = $job->payload;
if ($payload['type'] == 'SendEmail')
send_email(...);
});
You have several options to configure the worker. The options should be self-explanatory:
// optional configuration
$worker
->withMaxTotalRuntimeInSeconds(60)
->withMaxJobCount(100)
->withSleepTimeBetweenJobsInMilliseconds(1)
->withSleepTimeOnEmptyQueueInMilliseconds(100);
$size = $queue->size();
$job = $queue->get(12345);
TBD
TBD
TBD