PHP code example of mohamedhekal / event-outbox

1. Go to this page and download the library: Download mohamedhekal/event-outbox library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mohamedhekal / event-outbox example snippets


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,
    ]);
});

// routes/console.php or Kernel
Schedule::command('outbox:publish')->everyMinute();

'event_map' => [
    'order.created' => App\Events\OrderCreated::class,
],

use Hekal\EventOutbox\Support\IdempotentConsumer;

app(IdempotentConsumer::class)->once($message->uuid, function () {
    // side effects
}, consumer: 'billing');
bash
composer vendor:publish --tag=outbox-config
php artisan migrate
bash
php artisan outbox:publish --limit=100
php artisan outbox:purge --days=14