PHP code example of silawrenc / yocto

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

    

silawrenc / yocto example snippets



// 1. construct an instance passing in a callback for service resolution
$app = new Yocto([$container, 'get']);

// 2. add callbacks to the stack (FIFO)
$app->add(function ($app) {
    // returning false inside a callback would ensure no further callbacks are executed
    return !$app->get('auth')->isAuthenticated();
});

$app->add(function () {
    echo 'Hello world';
});

// 3. kick things off
$app->run();
// ...outputs hello world iff isAuthenticated is true