https://github.com/becklyn/eventor-symfony
🔮 A minimalistic library for abstracting pub/sub operations (ported for Symfony)
https://github.com/becklyn/eventor-symfony
Last synced: 3 months ago
JSON representation
🔮 A minimalistic library for abstracting pub/sub operations (ported for Symfony)
- Host: GitHub
- URL: https://github.com/becklyn/eventor-symfony
- Owner: Becklyn
- License: bsd-3-clause
- Created: 2022-08-23T13:25:40.000Z (almost 3 years ago)
- Default Branch: 3.x
- Last Pushed: 2022-09-20T08:13:33.000Z (over 2 years ago)
- Last Synced: 2025-01-14T03:13:56.851Z (4 months ago)
- Language: PHP
- Homepage: https://packagist.org/packages/becklyn/eventor-symfony
- Size: 39.1 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# eventor-symfony
🔮 A minimalistic library for abstracting pub/sub operations (ported for Symfony)
→ *eventor* is [clerk](https://github.com/Becklyn/clerk) for pub/sub 😉
→ the original Go implementation can be found [here](https://github.com/Becklyn/eventor)
## Installation
```sh
composer require becklyn/eventor-symfony
```## Supported brokers
*eventor* has builtin support for the following brokers:
- [Dapr Pub/sub API](https://docs.dapr.io/reference/api/pubsub_api/) - APIs for building portable and reliable microservices
## Usage
Being a minimalistic library, *eventor* only provides you with the basics. The rest is up to your specific need.
### Env variables
```env
DAPR_HOST=http://localhost:3500 # Default: (null)
DAPR_PUBSUB=pubsubname # Default: (null)
```### Publish
```php
class Message
{
public function __construct(
private readonly string $id,
private readonly string $body,
) {}public function id(): string
{
return $this->id;
}public function body(): string
{
return $this->body;
}
}
``````php
class PublishExample
{
public function __construct(
private readonly Publisher $publisher,
) {
$this->publisher->publish("topic", new Message(
id: "0",
body: "Hello World",
));
}
}
```### Subscribe
```php
class DaprSubscriptionController extends AbstractController
{
public function __construct(
private readonly DaprSubscriptionRegistry $subscriptionRegistry,
) {
new On(
fn (Message $msg) => echo($msg),
$this->$subscriber,
"topic",
);
}#[Route('/dapr/subscribe', methods: [Request::METHOD_GET])]
public function handleSubscribe() : Response
{
return $this->subscriptionRegistry->handleSubscribe();
}#[Route('/dapr/pubsubname/topic', methods: [Request::METHOD_POST])]
public function handleTopic(Request $request): Response
{
return $this->subscriptionRegistry->handleTopic($request);
}
}
```