PHP code example of flux-eco / aggregate-root

1. Go to this page and download the library: Download flux-eco/aggregate-root 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/ */

    

flux-eco / aggregate-root example snippets




co\DotEnv\Api::new()->load(__DIR__);

//initialize
fluxAggregateRoot\initialize();

//create
$correlationId = fluxValueObject\getNewUuid();
$actorEmail = '[email protected]';
$aggregateName = 'account';
$aggregateId = fluxValueObject\getNewUuid();
$payload = json_encode([
   "firstname" => "Emmett",
   "lastname" => "Brown"
]);
fluxAggregateRoot\create($correlationId, $actorEmail, $aggregateName, $aggregateId, $payload);


//change
$correlationId = fluxValueObject\getNewUuid();
$payload = json_encode([
    "firstname" => "Dr. Emmett",
    "lastname" => "Brown"
]);
fluxAggregateRoot\change($correlationId, $actorEmail, $aggregateName, $aggregateId, $payload);

//delete
fluxAggregateRoot\delete($correlationId, $actorEmail, $aggregateName, $aggregateId);