PHP code example of ludovicose / transaction-outbox

1. Go to this page and download the library: Download ludovicose/transaction-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/ */

    

ludovicose / transaction-outbox example snippets


event(new PostCreatedEvent($someData));

return [
    ...
    'subscribe_channels' => [
        'channelName'
    ],
    ...
];



namespace App\Providers;

... 

class EventServiceProvider extends ServiceProvider
{
    
    protected $listen = [
        ... 

        'channelName'                  => [
            SomeListener::class
        ]
        
        ...
    ];
}



namespace App\Listeners;

class SomeListener
{
    
    public function handle($event)
    {
        // $event data in event
    }
}


return [
    ...
    'enable_request_log' => true
    ...
];


return [
    ...
    'error_queue' => 'errors'
    ...
];



return [
    ...
    'delete_last_event_in_day' => 10
    ...
];


return [
    ...
    'connections' => [
        ... 
         'rabbitmq' => [
            'driver'     => 'rabbitmq',
            'connection' => 'default',
            'queue'      => env('RABBITMQ_QUEUE', 'default'),
        ],
        ... 
    ]   
    ...
];

bash
php artisan vendor:publish --provider="Ludovicose\TransactionOutbox\PackageServiceProvider" --tag="migrations"
bash
php artisan migrate
bash
php artisan vendor:publish --provider="Ludovicose\TransactionOutbox\PackageServiceProvider" --tag="config"
bash
$ php artisan events:listen
bash
$ php artisan events:repeat 2022-12-12
bash
$ php artisan request:repeat 2022-12-12
bash
$ php artisan events:resend-errors
bash
$ php artisan events:clear