PHP code example of rsousa / flows

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

    

rsousa / flows example snippets


protected function registerEvents(): void
{
    $this->pushEvent($frequentEvent);
    $this->pushEvent($streamEvent, failCount: 3, failAction: Behaviour::Exit);
    $this->pushEvent($httpEvent, failCount: 5, failAction: Behaviour::Continue);
}

public function __invoke(): string
{
    $this->waitForEvent(); // Start the race condition

    if ($this->winner === $event1) {
        return 'path_for_event1';
    } elseif ($this->winner === $event2) {
        return 'path_for_event2';
    }

    return 'default_path'; // Timeout or no event resolved
}
bash
php App/demo-branch-xor-gate.php