1. Go to this page and download the library: Download ride/lib-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.
<?phprequire_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ride / lib-queue example snippets
useride\library\queue\dispatcher\QueueDispatcher;
useride\library\queue\job\AbstractQueueJob;
useride\library\queue\worker\GenericQueueWorker;
useride\library\queue\QueueManager;
// push some jobs to the queuefunctionpushJobs(QueueDispatcher $queueDispatcher, array $files){
foreach ($files as $index => $file) {
// create a job with the needed references
$job = new MyQueueJob($file);
// you can optionally set a priority// jobs with a smaller priority value are more urgent
$job->setPriority(100);
// the queue dispatcher will select a queue and push your job to it
$queueJobStatus = $queueDispatcher->queue($job);
// you get the job id and more properties through the resulting queue job status
$files[$index] = $queueJobStatus->getId();
}
return $files;
}
// work horsefunctionwork(QueueManager $queueManager, $queue = 'default'){
// use a generic worker
$queueWorker = new GenericQueueWorker();
// this worker will poll the queue every 3 seconds for a job forever// you can provide a 0 second sleep time, the worker will then stop when it has no jobs
$queueWorker->work($queueManager, $queue, 3);
}
// example job which executes pngcrush on the provided pathclassMyQueueJobextendsAbstractQueueJob{
publicfunction__construct($path){
$this->path = $path;
}
publicfunctionrun(QueueManager $queueManager){
// you can update the description of your job while running
$queueManager->updateStatus($this->getJobId(), 'Checking file ' . $this->path);
if (file_exists($this->path) && !is_directory($this->path)) {
return;
}
$command = 'pngcrush -nofilecheck -rem alla -bail -blacken -ow ' . $this->path;
$queueManager->updateStatus($this->getJobId(), 'Invoking ' . $command);
exec($command, $output, $code);
$queueManager->updateStatus($this->getJobId(), $command . ' returned ' . $code);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.