Skip to content
This repository was archived by the owner on Dec 16, 2024. It is now read-only.

cerpus/php-pubsub

Repository files navigation

Cerpus\PubSub

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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published