1. Go to this page and download the library: Download javibravo/simpleue 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/ */
javibravo / simpleue example snippets
namespace MyProject\MyJob;
use Simpleue\Job\Job;
class MyJob implements Job {
public function manage($job) {
...
try {
...
} catch ( ... ) {
return FALSE;
}
...
return TRUE;
}
...
public function isStopJob($job) {
if ( ... )
return TRUE;
return FALSE;
}
public function isMyJob($job) {
if ( ... )
return TRUE;
return FALSE;
}
...
}
use Predis\Client;
use Simpleue\Queue\RedisQueue;
use Simpleue\Worker\QueueWorker;
use MyProject\MyJob;
$redisQueue = new RedisQueue(
new Client(array('host' => 'localhost', 'port' => 6379, 'schema' => 'tcp')),
'my_queue_name'
);
$myNewConsumer = new QueueWorker($redisQueue, new MyJob());
$myNewConsumer->start();
use Aws\Sqs\SqsClient;
use Simpleue\Queue\SqsQueue;
use Simpleue\Worker\QueueWorker;
use MyProject\MyJob;
$sqsClient = new SqsClient([
'profile' => 'aws-profile',
'region' => 'eu-west-1',
'version' => 'latest'
]);
$sqsQueue = new SqsQueue($sqsClient, 'my_queue_name');
$myNewConsumer = new QueueWorker($sqsQueue, new MyJob());
$myNewConsumer->start();
use Simpleue\Queue\BeanStalkdQueue;
use Simpleue\Worker\QueueWorker;
use Pheanstalk\Pheanstalk;
use MyProject\MyJob;
$beanStalkdClient = new Pheanstalk('localhost');
$beanStalkdQueue = new BeanStalkdQueue($beanStalkdClient, 'my_queue_name');
$myNewConsumer = new QueueWorker($beanStalkdQueue, new MyJob());
$myNewConsumer->start();
$myConsumer = new QueueWorker($myQueue, new MyJob());
$myConsumer->setMaxIterations(10); //any number
$myConsumer->start();
$myConsumer = new QueueWorker($myQueue, new MyJob(), 10);
$myConsumer->start();
$myConsumer = new QueueWorker($myQueue, new MyJob(), 10, true);
$myConsumer->start();
use Aws\Sqs\SqsClient;
use Simpleue\Queue\SqsQueue;
use Simpleue\Locker\MemcachedLocker;
use Simpleue\Worker\QueueWorker;
use MyProject\MyJob;
$memcached = new \Memcached();
$memcached->addServer('localhost', 11211);
$memcachedLocker = new MemcachedLocker($memcached);
$sqsClient = new SqsClient([
'profile' => 'aws-profile',
'region' => 'eu-west-1',
'version' => 'latest'
]);
$sqsQueue = new SqsQueue($sqsClient, 'my_queue_name', 20, 30);
$sqsQueue->setLocker($memcachedLocker);
$myNewConsumer = new QueueWorker($sqsQueue, new MyJob());
$myNewConsumer->start();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.