skolodyazhnyy / rabbitmq
This package is abandoned and no longer maintained.
No replacement package was suggested.
RabbitMQ library
1.0.4
2015-08-21 19:57 UTC
Requires
Requires (Dev)
- fabpot/php-cs-fixer: ~1.6
This package is not auto-updated.
Last update: 2021-06-02 10:18:30 UTC
README
This library provides lightweight wrapping classes to build RabbitMQ services. It's based on videlalvaro/php-amqplib AMQP client.
Standalone Usage
use Seven\RabbitMQ\Connection; use Seven\RabbitMQ\Manager; use Seven\RabbitMQ\Exchange; use Seven\RabbitMQ\Queue; // Intialize AMQP connection $connection = new Connection($host, $port, $user, $password, $vhost); $channel = $connection->channel(); // Create a manager $manager = new Manager($channel); // Register exchange, queue and create a binding $manager->addExchange(Exchange::configure($channel, 'my_exchange')); $manager->addQueue(Queue::configure($channel, 'my_queue')); $manager->bind('my_exchange', 'my_queue'); // Publish a message to queue $manager->getQueue('my_queue')->publish('..payload..', 'routing.key', array(...)); // Consume messages $manager->getExchange('my_exchange')->consume(function(\AMQPMessage $message) { echo $message->body . PHP_EOL; return true; });
Pimple Usage
use Pimple\Container; $container = new Container(); // Setup connection $container['rabbitmq'] = array( 'host' => 'localhost', 'port' => 5672, 'user' => 'guest', 'password' => 'guest', 'vhost' => '/', 'exchanges' => array( 'my_exchange' => null, ), 'queues' => array( 'my_queue' => null, ), 'bindings' => array( array('exchange' => 'my_exchange', 'queue' => 'my_queue') ) ); // Register services $container->register(new \Seven\RabbitMQ\Provider\Pimple\RabbitMqProvider()); // Publish a message to queue $container['rabbitmq.manager']->getQueue('my_queue')->publish('..payload..', 'routing.key', array(...)); // Consume messages $container['rabbitmq.manager']->getExchange('my_exchange')->consume(function(\AMQPMessage $message) { echo $message->body . PHP_EOL; return true; });