1. Go to this page and download the library: Download jenwachter/php-redis-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.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jenwachter / php-redis-queue example snippets
$predis = new Predis\Client();
$worker = new PhpRedisQueue\QueueWorker($predis, 'files');
$worker->addCallback('upload', function (array $data) {
// create various crop sizes
// optimize
// ...
});
$worker->addCallback('delete', function (array $data) {
// delete all created crop sizes
// ...
});
$worker->work();
// trigger: user uploads a file...
$predis = new Predis\Client();
$client = new PhpRedisQueue\Client($predis);
// gather data
$predis = new Predis\Client();
$client = new PhpRedisQueue\Client($predis);
// create a job group
$group = $client->createJobGroup();
// add jobs to the group
$group->push('queuename', 'jobname');
$group->push('another-queuename', 'jobname');
$group->push('queuename', 'jobname');
$group->push('queuename', 'jobname');
// add jobs in the group to the queue
$group->queue();
$predis = new Predis\Client();
$worker = new PhpRedisQueue\QueueWorker($predis, 'queuename');
$worker->addCallback('jobname', fn (array $data) true);
$worker->addCallback('group_after', function ($group, $success) {
// respond to group completion
});
$worker->work();
$predis = new Predis\Client();
$worker = new PhpRedisQueue\QueueWorker($predis, 'queuename');
$predis = new Predis\Client();
$worker = new PhpRedisQueue\QueueWorker($predis, 'queuename', [
'logger' => new Logger(),
]);
$predis = new Predis\Client();
$client = new \PhpRedisQueue\Client($predis);
$predis = new Predis\Client();
$worker = new PhpRedisQueue\QueueWorker($predis, 'queuename', [
'logger' => new Logger()
]);
$predis = new Predis\Client();
$client = new \PhpRedisQueue\Client($predis);
$group = $group->createJobGroup($total = null, $data = []);
bash
composer
bash
$ php files.php
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.