cerpus / pubsub
Client for RabbitMQ pub-sub
Installs: 8 710
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: 8.0.*|8.1.*|8.2.*|8.3.*
- php-amqplib/php-amqplib: ^3.1
- psr/log: ^1.0|^2.0|^3.0
Requires (Dev)
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-12-16 08:57:17 UTC
README
Simple publish-subscribe for RabbitMQ and PHP.
Requirements
- PHP 8.0, 8.1, or 8.2
- The extensions required by php-amqplib
Installation
composer require cerpus/pubsub
Usage
use Cerpus\PubSub\Connection\ConnectionFactory; use Cerpus\PubSub\PubSub; $connectionFactory = new ConnectionFactory('localhost', 5672, 'guest', 'guest', '/'); $pubSub = new PubSub($connectionFactory->connect()); // publish your own messages $pubSub->publish('some_other_topic', 'some data'); // listen for incoming messages $pubSub->subscribe('subscriber_name', 'some_topic', function (string $data) { // do something with the data echo "$data\n"; }); $pubSub->listen();
Future scope
- Support ext-amqp, queue-interop
- Handle more exceptions from underlying libraries
- Support configuring flags like auto-delete, etc.
License
This package is released under the MIT license. See the LICENSE
file for more
information.