PHP code example of symbid / chainlink

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

    

symbid / chainlink example snippets


class MyHandler implements HandlerInterface
{
    // ... fulfill interface ...
}

$handler = new MyHandler();

// Create a Context to chain responsibilities
$context = new DMS\Chainlink\Context();
$context->addHandler($handler);

// Pass in an item to be handled
$context->handle($input);

// You can also get the handler as a return value
$handler = $context->getHandlerFor($input);

// You may have need of returning multiple handlers
$handler = $context->getAllHandlersFor($input);

// Create a Context to chain responsibilities
$context = new DMS\Chainlink\Context();
$context->addHandler($handler1, 10);
$context->addHandler($handler2, 1000);
$context->addHandler($handler3);

// Pass in an item to be handled
$context->handle($input);