PHP code example of flux-eco / global-stream

1. Go to this page and download the library: Download flux-eco/global-stream 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 / global-stream example snippets




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

//initialize
fluxGlobalStream\initialize();


//publish state change
$correlationId = fluxValueObject\getNewUuid();
$createdBy = '[email protected]';
$subject = 'AggregateRoot';
$subjectId = fluxValueObject\getNewUuid();
$subjectSequence = 1;
$subjectName = 'account';
$jsonObjectSchema = json_encode(yaml_parse(file_get_contents('schemas/domain/account.yaml')));
$eventName = 'aggregateRootCreated';
$currentState = json_encode([
    "firstname" => [
        "value" => "Emmett",
        "isEntityId" => false
    ],
    "lastname" => [
        "value" => "Brown",
        "isEntityId" => false
    ]
]);
fluxGlobalStream\publishStateChange(
    $correlationId,
    $createdBy,
    $subject,
    $subjectId,
    $subjectSequence,
    $subjectName,
    $jsonObjectSchema,
    $eventName,
    $currentState
);


//republish all states
fluxGlobalStream\republishAllStates(
    [$subjectName]
);