enl / amqp-workers
This library provides more object-oriented way to create amqp workers and producers
Requires
- php: ~5.6|~7.0
- php-amqplib/php-amqplib: 2.6.*
Requires (Dev)
- mockery/mockery: ~0.9
- phpunit/phpunit: ~5.4
- scrutinizer/ocular: ~1.1
- squizlabs/php_codesniffer: ~2.3
This package is auto-updated.
Last update: 2024-10-29 04:14:48 UTC
README
All this library does is providing more fluent experience with AMQP. Original phpamqplib has very strange approach to its functions declarations.
I decided to create a tiny layer of abstraction which provides a bit more flexible interface:
$consumer = Consumer::factory($connection) ->withQueue(new Queue('consume_from')) ->withWorker($worker) ->run();
That is very short basic setup, Consumer
has much more functions. Read the manual for more detailed description.
Features
- More fluent and flexible interface than original php-amqplib library;
- Very lazy approach, amqp-related stuff is called only when you call
run
orproduce
functions.
Install
composer require enl/amqp-workers
Usage
// Create AMQPConnection $connection = new AMQPLazyConnection(); // We're using static `factory` function only for convenience with fluent interface $consumer = Consumer::factory($connection) // set queue definition. all parameters are default ->withQueue(new Queue('consume_from')) // Worker is an object of WorkerInterface which handles given message body ->withWorker($worker) // declare and start consuming the queue ->run();
Change log
Please see CHANGELOG for more information what has changed recently.
Testing
composer test
Contributing
Please see CONTRIBUTING and CONDUCT for details.
Security
If you discover any security related issues, please email deadyaga@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.