PHP code example of opxcore / pipeline

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

    

opxcore / pipeline example snippets


class Pipe
{
    public function handle($passable, callable $next)
    {
        // here you can perform modifications of passable 
        
        // and pass it to next pipe
        $modified = $next($passable);
        
        // and finally you can modify returned value here 
        
        return $modified;
    }
}

use OpxCore\Container\Container;
use OpxCore\Pipeline\Pipeline;

$container = new Container;
$pipeline = new Pipeline($container);

$result = $pipeline
    ->send('some value')
    ->through(['pipe_1', 'pipe_2'])
    ->via('handle')
    ->then(function ($passable){
        return $passable;
    })
    ->run();