PHP code example of ensi / laravel-initial-event-propagation

1. Go to this page and download the library: Download ensi/laravel-initial-event-propagation 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/ */

    

ensi / laravel-initial-event-propagation example snippets


$holder = resolve(InitialEventHolder::class);
var_dump($holder->getInitialEvent());
$holder->setInitialEvent(new InitialEventDTO(...));

$handlerStack = new HandlerStack(Utils::chooseHandler());
$handlerStack->push(new PropagateInitialEventLaravelGuzzleMiddleware());

public function bootstrap()
{
    parent::bootstrap();
    (new SetInitialEventArtisanMiddleware())->handle();
}

use Ensi\LaravelInitialEventPropagation\Job;

// Extend the job from package
class TestJob extends Job implements ShouldQueue 
{
    public function __construct(protected Customer $customer)
    {
        // Do not forget to call parent constuctor
        parent::__construct();
    }

    public function handle()
    {
        // InitialEvent is automatically persisted to InitialEventHolder via job middleware in parent class, 
        // You do not need to persist it manually
    }
}
 
'job_class' => \Ensi\LaravelInitialEventPropagation\ActionJob::class,
bash
php artisan vendor:publish --provider="Ensi\LaravelInitialEventPropagation\LaravelInitialEventPropagationServiceProvider"