agluh/outbox-bundle
Laravel outbox pattern bundle for reliable event publishing: capture domain events in an outbox table within your transaction, then dispatch them asynchronously to queues or brokers. Helps avoid dual-write issues and improves consistency between your DB and integrations.
EventDispatcher vs. Laravel’s Events facade, Doctrine vs. Eloquent, Symfony Lock vs. Laravel’s mutex alternatives).outbox_message table (Doctrine schema). Laravel’s migrations can adapt this.EventDispatcher must be replaced with Laravel’s Events or a custom bridge (e.g., symfony/event-dispatcher via Composer).Console commands for polling. Laravel’s queues (e.g., php artisan queue:work) or scheduler can replace this.Illuminate\Support\Facades\Lock or a package like spatie/laravel-lock.EventDispatcher, Lock).EventDispatcher emits events differently than Laravel’s Events::dispatch(). A custom event listener bridge is needed.ramsey/uuid-doctrine must be adapted for Eloquent or replaced with Laravel’s webpatser/uuid.matthiasnoback/symfony-dependency-injection-test) are incompatible; Laravel’s Pest/PHPUnit will require custom fixtures.Events/Listeners integrate with the Outbox’s Symfony-style event dispatching?outbox_message table schema translate to Laravel migrations?Console commands with Laravel queues (e.g., busy queue) or a custom scheduler job?Symfony Lock isn’t directly replaceable? (e.g., database SELECT ... FOR UPDATE or spatie/laravel-lock).Pest/PHPUnit)?| Symfony Component | Laravel Equivalent | Adaptation Strategy |
|---|---|---|
EventDispatcher |
Events facade |
Custom bridge class (e.g., SymfonyEventDispatcher) |
Doctrine ORM |
Eloquent | Hybrid: Use Doctrine for outbox only, or migrate fully |
Symfony Lock |
spatie/laravel-lock |
Replace with Lock facade or DB locks |
| Console commands | Artisan commands / Queues | Convert to Laravel jobs or scheduled tasks |
Phase 1: Proof of Concept (PoC)
outbox_message table via Laravel migration.OrderCreated).Phase 2: Symfony Dependency Replacement
EventDispatcher with a Laravel-compatible bridge.Symfony Lock with spatie/laravel-lock or DB locks.Doctrine entities to Eloquent models (or vice versa).Phase 3: Full Integration
Events::dispatch().class SymfonyEventDispatcherBridge {
public function dispatch(object $event) {
Events::dispatch($event);
}
}
Console commands with Laravel jobs (e.g., ProcessOutboxMessages).database, redis, etc.) for polling.outbox_message table (adapted from Symfony’s schema).Schema::create('outbox_message', function (Blueprint $table) {
$table->id();
$table->uuid('message_id');
$table->string('type');
$table->json('payload');
$table->timestamp('occurred_at')->useCurrent();
$table->boolean('processed')->default(false);
$table->timestamps();
});
Outbox class to handle store() and getUnprocessed().OrderCreated) to publish to the outbox.outbox_message growth.processed_at delays and failure rates (e.g., with Laravel Scout or Prometheus).How can I help you explore Laravel packages today?