Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/daalvand/pub-sub
This package used to publish and subscribe with Regis or Kafka
https://github.com/daalvand/pub-sub
kafka laravel pub-sub publish-subscribe pubsub redis
Last synced: 4 days ago
JSON representation
This package used to publish and subscribe with Regis or Kafka
- Host: GitHub
- URL: https://github.com/daalvand/pub-sub
- Owner: daalvand
- Created: 2021-09-24T09:40:11.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-09-24T10:06:18.000Z (over 3 years ago)
- Last Synced: 2024-12-05T22:34:33.370Z (22 days ago)
- Topics: kafka, laravel, pub-sub, publish-subscribe, pubsub, redis
- Language: PHP
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PUB SUB
* This package used to publish and subscribe with Regis or Kafka
# installation
## install package
run `composer require daalvand/pubsub`### publish provider
#### Laravel
* `php artisan vendor:publish --provider="Daalvand\PubSub\PubSubServiceProvider"`#### Lumen
* Add the service provider to `bootstrap/app.php` file:
```php
register(Daalvand\PubSub\PubSubServiceProvider::class);
```Copy the config files from `/vendor/daalvand/pubsub/src/config` to `config` directory. Then configure it in `/bootstrap/app.php` file:
```php
configure("pub-sub");
```## USAGE
#### Publisher
```php
use Daalvand\PubSub\Facades\Publisher;
Publisher::publish('channel_name', $data);
```
#### Subscriber
```php
use Daalvand\PubSub\Facades\Subscriber;
use Daalvand\PubSub\Message;Subscriber::subscribe(['channel_one', 'channel_two'], function (Message $message) {
switch ($message->getType()) {
case 'channel_one':
//a
break;
case 'channel_two':
//b
break;
}
}, 'user');```
**NOTE**Notice that the real channel name is like below:
`{microservice_name}_{channel_name}_{environment}`