PHP code example of dakujem / cumulus

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

    

dakujem / cumulus example snippets


$foobarSuffixTube = Pipeline::tube([
    function (string $a): string {
        return $a . 'foo';
    },
    function (string $a): string {
        return $a . 'bar';
    },
]);
$foobarSuffixTube('iam'); // 'iamfoobar'

$foobarPrefixMiddleware = Pipeline::onion([
    function (string $a, callable $next): string {
        return $next('bar' . $a);
    },
    function (string $a, callable $next): string {
        return $next('foo' . $a);
    },
]);
$foobarPrefixMiddleware('youare'); // 'foobaryouare'

$dsn = new Dsn('mysqli://john:secret@localhost/my_db');

// with optional default values
$driver = $dsn->get('driver', 'mysqli');
$port = $dsn->get('port', 3306);
// without optional defaults
$user = $dsn->get('username');
// using magic and array accessors:
$user = $dsn->username;
$user = $dsn['username'];
$pass = $dsn->password ?? '';