PHP code example of dance-engineer / event-sauce-prooph-event-store

1. Go to this page and download the library: Download dance-engineer/event-sauce-prooph-event-store 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/ */

    

dance-engineer / event-sauce-prooph-event-store example snippets



function createInGeneral(): \EventSauce\EventSourcing\AggregateRootRepository
{
    /** @var \Prooph\EventStore\EventStore $eventStore */
    // Your Event Store has implementation has to use EventSauceMessageFactory to create messages from data!!

    $configuredEventStore = new ConfiguredEventStore($eventStore);
    return new ProophEventStoreRepository(\EventSauce\EventSourcing\AggregateRoot::class, $configuredEventStore);
}

function createConcreteExample(): \EventSauce\EventSourcing\AggregateRootRepository
{
    $eventStore = new \Prooph\EventStore\Pdo\PostgresEventStore(
        new EventSauceMessageFactory(), // Your Event Store has to use this class to create messages from data!!
        new \PDO('you know how to configure a PDO connection, don\'t you?'),
        new \Prooph\EventStore\Pdo\PersistenceStrategy\PostgresAggregateStreamStrategy()
    );

    $configuredEventStore = new ConfiguredEventStore($eventStore, true);
    return new ProophEventStoreRepository(\EventSauce\EventSourcing\AggregateRoot::class, $configuredEventStore);
}

function createFullConfig(): \EventSauce\EventSourcing\AggregateRootRepository
{
    /** @var \Prooph\EventStore\EventStore $eventStore */
    // Your Event Store has implementation has to use EventSauceMessageFactory to create messages from data!!

    $configuredEventStore = new ConfiguredEventStore($eventStore, false, ['stream_tag' => 'banana'], new
    \Prooph\EventStore\StreamName('lama'));
    return new ProophEventStoreRepository(\EventSauce\EventSourcing\AggregateRoot::class, $configuredEventStore, new
    \EventSauce\EventSourcing\CollectingMessageDispatcher(), new \EventSauce\EventSourcing\DefaultHeadersDecorator());
}