1. Go to this page and download the library: Download riverline/worker-bundle 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/ */
riverline / worker-bundle example snippets
$provider = $this->get('riverline_worker.provider.predis');
$provider->put('ThisIsMyQueue', 'Hello World');
$queue = $this->get('riverline_worker.queue.queue1');
echo $queue->count()." item(s) in the queue";
// src/Acme/DemoBundle/Command/DemoWorkerCommand.php
namespace Acme\DemoBundle\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Riverline\WorkerBundle\Command\Worker;
use Riverline\WorkerBundle\Command\WorkerControlCodes;
class DemoWorkerCommand extends Worker
{
protected function configureWorker()
{
$this
// Queue name from the configuration
->setQueueName('queue1')
// Inhered Command methods
->setName('demo-worker')
->setDescription('Test a worker')
;
}
protected function executeWorker(InputInterface $input, OutputInterface $output, $workload)
{
$output->writeln($workload);
// Stop worker and dot not process other workloads
if ($someReasonToStopAndExit)
{
return WorkerControlCodes::STOP_EXECUTION;
}
// else continue
return WorkerControlCodes::CAN_CONTINUE;
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.