dmasior / querabilis
This package is abandoned and no longer maintained.
No replacement package was suggested.
Simple PHP Queue
0.6
2019-06-10 16:11 UTC
Requires
- php: ^7.2
- jms/serializer: ^3.0
- symfony/yaml: ^4.0
Requires (Dev)
- aws/aws-sdk-php: ^3.99
- codeception/codeception: ^3.0
- fzaninotto/faker: ^1.8
- mockery/mockery: ^1.2
- pda/pheanstalk: ^4.0
- php-amqplib/php-amqplib: ^2.9
- phpunit/phpunit: ^8.1
- predis/predis: ^1.1
- ramsey/uuid: ^3.8
- slevomat/coding-standard: ^5.0
- squizlabs/php_codesniffer: *
- vimeo/psalm: ^3.4
Suggests
- aws/aws-sdk-php: When using AWS SQS driver
- pda/pheanstalk: When using Beanstalk driver
- php-amqplib/php-amqplib: When using AMQP driver
- predis/predis: When using Redis driver
README
Compliant with JAVA Queue interface
Installation
$ composer require initx/querabilis
Usage
Driver
use Initx\Querabilis\Driver\FilesystemQueue; $queue = new FilesystemQueue('./queue');
Push to queue
use Initx\Querabilis\Envelope; $envelope = new Envelope('Payload goes here'); $queue->add($envelope);
Pull form queue
$envelope = $queue->remove(); $envelope->getPayload(); // "Payload goes here"
Currently supported drivers
- Amazon SQS
- Redis (Predis)
- AMQP
- Beanstalkd
- Filesystem
- In memory
Each driver implements Queue interface.
Summary of Queue interface
Insert
add(e)
- inserts an element if possible, otherwise throwing exceptionoffer(e)
- inserts an element if possible, otherwise returning false
Remove
remove()
- remove and return head of queue, otherwise throwing exceptionpoll()
- remove and return head of queue, otherwise returning null
Examine
element()
- return but do not remove head of queue, otherwise throwing exceptionpeek()
- return but do not remove head of queue, otherwise returning null
More examples
Redis (Predis) driver
use Predis\Client; use Initx\Querabilis\Driver\RedisQueue; $client = new Client(['host' => '127.0.0.1']); $queue = new RedisQueue($client, 'queueName');
AWS SQS driver
use Aws\Sqs\SqsClient; use Initx\Querabilis\Driver\SqsQueue; $client = new SqsClient(your_sqs_client_config); $queue = new SqsQueue($client, 'queueName');
In memory driver
use Initx\Querabilis\Driver\InMemoryQueue; $queue = new InMemoryQueue();
Beanstalkd driver
use Pheanstalk\Pheanstalk; use Initx\Querabilis\Driver\BeanstalkdQueue; $client = Pheanstalk::create([your_beanstalkd_config]); $queue = new BeanstalkdQueue($client);
AMQP driver
use PhpAmqpLib\Connection\AMQPStreamConnection; use Initx\Querabilis\Driver\AmqpQueue; $connection = new AMQPStreamConnection([your_amqp_config]); $queue = new AmqpQueue($connection, 'queueName', 'exchange');