PHP code example of webpt / aquaduck

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

    

webpt / aquaduck example snippets


use Webpt\Aquaduck\Aquaduck;


$pipeline->bind(function($value, $next) {
    $next($value + 5);
});

echo $pipeline(5); //10

function ($error, $subject, $next) { }

$pipe = new Aquaduck();       // Middleware collection
$pipe->bind(/* ... */);       // repeat as necessary

$superPipe = new Aquaduck();  // New Middleware collection
$superPipe->bind($pipe);      // Middleware attached as a group

class Aquaduck implements MiddlewareInterface
{
    public function bind($middleware, $priority = 1);
    public function __invoke(
        $subject,
        $out = null
    );
}

function (
    $subject,
    $err = null
) {
}

class Next
{
    public function __invoke(
        $subject,
        $err = null
    );
}

function ($subject, $next) use ($helperClass)
{
    $subject = $helperClass->help($subject);
    return $next($subject);
}

function ($subject, $next)
{
    try {
        // try some operation...
    } catch (Exception $e) {
        return $next($subject, $e); // Next registered error middleware will be invoked
    }
}