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

Maintainers

Package info

github.com/mohamedhekal/event-outbox

pkg:composer/mohamedmohamedhekal/event-outbox

Transparency log

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.0 2026-07-16 14:23 UTC

This package is auto-updated.

Last update: 2026-07-16 14:40:19 UTC


README

CI License: MIT PHP Laravel

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