sammy-boy/eventbus-core

Reusable event bus infrastructure for Laravel microservices

Maintainers

Package info

github.com/sammy-boy/eventbus-core

pkg:composer/sammy-boy/eventbus-core

Statistics

Installs: 200

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 0

v1.0.2 2026-02-06 07:07 UTC

This package is auto-updated.

Last update: 2026-03-06 07:19:18 UTC


README

Repository: https://github.com/sammy-boy/eventbus-core

# SammyBoy EventBus Core

Reusable, opinionated Event Bus infrastructure for Laravel microservices.

Built for scalable, event-driven architectures using RabbitMQ and Redis-backed idempotency.

---

## Features

- Standardized event envelope (meta + data)
- Automatic idempotency protection (Redis)
- RabbitMQ publisher with confirmations
- Config-driven consumer
- Dead Letter Exchange support
- Slow-event monitoring
- Laravel auto-discovery support
- Production-ready defaults with flexibility

---

## Installation

```bash
composer require sammy-boy/eventbus-core

Configuration

Publish configuration:

php artisan vendor:publish --tag=eventbus-config

Example:

return [

    'exchanges' => [
        'auth.events',
        'business.events',
    ],

    'queues' => [
        [
            'name' => 'auth_ms.business_events',
            'exchange' => 'business.events',
            'routing_keys' => [
                'tenant.registration.initiated',
            ],
        ],
    ],

    'handlers' => [
        'tenant.registration.initiated' => ProcessTenantCreation::class,
    ],

];

Publishing Events

use SammyBoy\EventBus\RabbitMQService;

$eventBus->publish(
    exchange: 'business.events',
    routingKey: 'tenant.registration.initiated',
    data: [
        'auth_user_id' => 12,
        'email' => 'user@example.com',
    ]
);

Envelope automatically becomes:

{
  "meta": {
    "id": "...",
    "type": "tenant.registration.initiated",
    "source": "auth-service",
    "timestamp": "...",
    "correlation_id": "..."
  },
  "data": { ... }
}

Consuming Events

Run:

php artisan eventbus:consume

Options:

php artisan eventbus:consume --queue=auth_ms.business_events
php artisan eventbus:consume --exchange=business.events

Idempotency

Prevents duplicate event execution.

Configured via:

'idempotency' => [
    'enabled' => true,
    'ttl' => 3600,
    'redis_prefix' => 'event:processed:',
],

Monitoring

Detect slow events:

'monitoring' => [
    'enabled' => true,
    'slow_event_threshold' => 5000, // ms
],

Architecture Philosophy

Opinionated but flexible.

This package enforces:

  • Standardized event structure
  • Config-driven topology
  • Explicit handler mapping

But allows:

  • Custom queue naming
  • Custom exchanges
  • Retry behavior overrides
  • Dead-letter configuration
  • Performance tuning

Requirements

  • PHP 8.4+
  • Laravel 11 / 12+
  • RabbitMQ
  • Redis

License

MIT

Author

Sammy Orondo Lead Developer — SammyBoy https://github.com/sammy-boy