PHP code example of alexmanno / pipeline-remix

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

    

alexmanno / pipeline-remix example snippets


 class MyCoolStage implements AlexManno\Remix\Pipelines\Interfaces\StageInterface
 {
    /**
     * @param Payload $payload
     */
    public function __invoke(Payload $payload)
    {
        $payload->setData('Hello!');
        
        return $payload;
    }
}

class Payload implements AlexManno\Remix\Pipelines\Interfaces\PayloadInterface
{
    /** @var RequestInterface */
    public $request;
    /** @var ResponseInterface */
    public $response;
}

// -- Initialized objects: $payload, $pipeline, $stage1, $stage2 --

$pipeline
    ->pipe($stage1) // Add $stage1 to queue
    ->pipe($stage2); // Add $stage2 to queue

$pipeline($payload);  // Run pipeline: invoke $stage1 and then $stage2 with payload from $stage1

// -- Initialized objects: $payload, $pipeline1, $pipeline2, $stage1, $stage2 --

$pipeline1->pipe($stage1); // Add $stage1 to $pipeline1
$pipeline2->pipe($stage2); // Add $stage2 to $pipeline2

$pipeline1->add($pipeline2); // Add stages from $pipeline2

$payload = $pipeline1($payload); // Run pipeline: invoke $stage1 (from $pipeline1) and then $stage2 (from $pipeline2) with payload from $stage1