1. Go to this page and download the library: Download resquebundle/resque 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/ */
resquebundle / resque example snippets
php
namespace My;
use ResqueBundle\Resque\Job;
use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\Common\Persistence\ObjectManager;
class MyJob extends Job
{
/**
* @var string The queue name
*/
public $queue = 'myqueue';
/**
* @var ManagerRegistry
*/
private $registry;
/**
* @var ObjectManager
*/
private $em;
/**
* Use the __construct to inject your dependencies
*
* @param array $args
* @param ManagerRegistry $registry
*/
public function __construct(
$args = [],
ManagerRegistry $registry
) {
$this->registry = $registry;
$this->em = $registry->getManager();
parent::__construct($args);
}
public function run($args)
{
file_put_contents($args['file'], $args['content']);
}
}
php
// get resque (only if service has been made public - else USE DI LIKE YOU SHOULD)
// $resque = $this->get('ResqueBundle\Resque\Resque');
// create your job
$job = new MyJob();
$job->args = array(
'file' => '/tmp/file',
'content' => 'hello',
);
// enqueue your job
$resque->enqueue($job);
php
// get resque (only if service has been made public - else use DI LIKE YOU SHOULD)
//$resque = $this->get('ResqueBundle\Resque\Resque');
// create your job
$job = new MyJob();
$job->args = array(
'file' => '/tmp/file',
'content' => 'hello',
);
// enqueue your job to run at a specific \DateTime or int unix timestamp
$resque->enqueueAt(\DateTime|int $at, $job);
// or
// enqueue your job to run after a number of seconds
$resque->enqueueIn($seconds, $job);
php
namespace My;
use ResqueBundle\Resque\Job;
class MyJob extends Job
{
public function __construct()
{
$this->queue = 'my_queue';
}
public function run($args)
{
...
}
}
php
// create your job
$job = new MyJob();
$job->queue = 'my_queue';
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.