PHP code example of avonnadozie / liteonion
1. Go to this page and download the library: Download avonnadozie/liteonion 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/ */
avonnadozie / liteonion example snippets
class BeforeLayer implements LayerInterface {
public function peel($object, Closure $next)
{
$object->runs[] = 'before';
return $next($object);
}
}
class AfterLayer implements LayerInterface {
public function peel($object, Closure $next)
{
$response = $next($object);
$object->runs[] = 'after';
return $response;
}
}
$object = new StdClass;
$object->runs = [];
$onion = new Onion;
$end = $onion->layer([
new AfterLayer(),
new BeforeLayer(),
new AfterLayer(),
new BeforeLayer()
])
->peel($object, function($object){
$object->runs[] = 'core';
return $object;
});
var_dump($end);