Background jobs using Beanstalk (Symfony bundle)
$ composer require visual-craft/work-queue-bundle
##config/packages/visual_craft_work_queue.yaml
visual_craft_work_queue:
connections:
default: ~
queues:
test_queue:
connection: default
worker: 'App\BackgroundJob\Worker\TestWorker'
<?php
declare(strict_types=1);
namespace App\BackgroundJob\Worker;
use VisualCraft\WorkQueue\Worker\JobMetadata;
use VisualCraft\WorkQueue\Worker\WorkerInterface;
class TestWorker implements WorkerInterface
{
public function work($payload, JobMetadata $metadata): void
{
//..
}
}
services:
App\Command\TestCommand:
arguments:
- '@visual_craft_work_queue.manager.test_queue'
//..
private QueueManager $queueManager;
public function __construct(QueueManager $queueManager)
{
$this->queueManager = $queueManager;
}
//..
$this->queueManager->add('mixed payload');
//..
This code is released under the MIT license. See the complete license in the file: LICENSE