mohamedmohamedhekal / event-outbox
This package is abandoned and no longer maintained.
The author suggests using the mohamedhekal/event-outbox package instead.
Transactional outbox for reliable domain events in Laravel
v0.1.0
2026-07-16 14:23 UTC
Requires
- php: ^8.2
- illuminate/console: ^11.0|^12.0
- illuminate/contracts: ^11.0|^12.0
- illuminate/database: ^11.0|^12.0
- illuminate/events: ^11.0|^12.0
- illuminate/support: ^11.0|^12.0
Requires (Dev)
- laravel/pint: ^1.18
- orchestra/testbench: ^9.0|^10.0
- pestphp/pest: ^3.0
- pestphp/pest-plugin-laravel: ^3.0
- phpstan/phpstan: ^2.0
README
Search terms: laravel, outbox, domain-events, reliability, messaging, php, laravel-package, transactional-outbox, events, queues.
Transactional outbox for Laravel: persist domain events in the same DB transaction as your business write, then publish them reliably with a worker.
Problem
DB::commit() + event() / Queue::push() is a dual-write. If the process dies between them, state and events diverge. The outbox pattern makes event emission part of the transaction.
Installation
composer require mohamedhekal/event-outbox php artisan vendor:publish --tag=outbox-config php artisan migrate
Usage
use Hekal\EventOutbox\Facades\Outbox; use Illuminate\Support\Facades\DB; DB::transaction(function () use ($order) { $order->save(); Outbox::record('order.created', [ 'id' => $order->id, 'total' => $order->total, ]); });
Schedule the publisher:
// routes/console.php or Kernel Schedule::command('outbox:publish')->everyMinute();
Map types to Laravel events in config/outbox.php:
'event_map' => [ 'order.created' => App\Events\OrderCreated::class, ],
OrderCreated should accept array $payload (and optionally array $headers).
Every successful publish also fires OutboxMessagePublished.
Idempotent consumers
use Hekal\EventOutbox\Support\IdempotentConsumer; app(IdempotentConsumer::class)->once($message->uuid, function () { // side effects }, consumer: 'billing');
Commands
php artisan outbox:publish --limit=100 php artisan outbox:purge --days=14
Testing
composer install && composer test
License
MIT