1. Go to this page and download the library: Download visual-craft/work-queue 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/ */
visual-craft / work-queue example snippets
use Pheanstalk\Pheanstalk;
use VisualCraft\WorkQueue\Logger;
use VisualCraft\WorkQueue\QueueManager;
$manager = new QueueManager(
Pheanstalk::create('127.0.0.1', 11300),
'some_queue',
new Logger(null)
);
use VisualCraft\WorkQueue\QueueProcessor;
use VisualCraft\WorkQueue\Worker\JobMetadata;
use VisualCraft\WorkQueue\Worker\WorkerInterface;
class SomeWorker implements WorkerInterface
{
public function work($payload, JobMetadata $metadata): void
{
// Process job
}
}
// Create the queue processor and provide it with the worker
$processor = new QueueProcessor(
$manager,
new SomeWorker(),
);
// Process the queue
while($processor->process()) {}
$adder = new JobAdder($manager);
$id = $adder->add('some data');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.