PHP code example of uafrica / delayed-jobs
1. Go to this page and download the library: Download uafrica/delayed-jobs 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/ */
uafrica / delayed-jobs example snippets
$job = new \DelayedJob\DelayedJob\Job();
$job->setWorker('RunJob') //References a \App\Worker\RunJobWorker class
->setPayload($payload) //An array of payload data
->setRunAt(new Time('+1 hour')) //Run this job in an hour
->setPriority('10'); //Priority of 10
\DelayedJob\DelayedJob\JobManager::instance()
->enqueue($job);
namespace DelayedJobs\Worker;
use DelayedJobs\DelayedJob\Job;
use DelayedJobs\Result\Success;
/**
* Class TestWorker
*/
class TestWorker implements JobWorkerInterface
{
/**
* @param \DelayedJobs\DelayedJob\Job $job The job that is being run.
* @return bool
*/
public function __invoke(Job $job)
{
return new Success('We ran!')
}
}