1. Go to this page and download the library: Download bricev/jobqueue 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/ */
bricev / jobqueue example snippets
use JobQueue\Domain\Job\ExecutableJob;
use JobQueue\Domain\Task\Task;
use Psr\Log\LoggerAwareTrait;
final class DummyJob implements ExecutableJob
{
use LoggerAwareTrait;
/**
*
* @param Task $task
*/
function setUp(Task $task)
{
// This is called before the `perform()` method
/** @todo prepare the job execution */
}
/**
*
* @param Task $task
*/
function perform(Task $task)
{
/** @todo do the job! */
}
/**
*
* @param Task $task
*/
function tearDown(Task $task)
{
// This is called after the `perform()` method
/** @todo clean up after the job execution */
}
}
use JobQueue\Domain\Task\Profile;
use JobQueue\Domain\Task\Task;
use JobQueue\Tests\Domain\Job\DummyJob;
$task = new Task(
new Profile('foobar'),
new DummyJob,
[
'foo' => 'bar',
// [...]
]
);
use JobQueue\Infrastructure\RedisQueue;
use Predis\Client;
$predis = new Client('tcp://localhost:6379');
$queue = new RedisQueue($predis);
use JobQueue\Infrastructure\ServiceContainer;
$queue = ServiceContainer::getInstance()->queue;