1. Go to this page and download the library: Download adagio/middleware 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/ */
adagio / middleware example snippets
// I want to solarize, rotate, unblur and then sepia my image (parameters are
// voluntarily omitted for clarity).
$image = (new SepiaFilter)
->filter((new UnblurFilter)
->filter((new RotateFilter)
->filter((new SolarizedFilter)
->filter(new Image('/path/to/image')))));
use Adagio\Middleware\Stack;
$pipe = new Stack([
new SolarizedFilter,
new RotateFilter,
new UnblurFilter,
new SepiaFilter,
]);
$image = $stack(new Image('/path/to/image'));
function (Image $image, callable $next): Image
{
// Maybe do something with $image
$resultingImage = $next($image);
// Maybe do something with $resultingImage
return $resultingImage;
}
function (SqlQuery $query, ResultSet $resultSet, callable $next): ResultSet
final class QueryCache
{
// ...
public function __invoke(SqlQuery $query, ResultSet $resultSet, callable $next): ResultSet
{
// If the query is already in cache, return the ResultSet and don't
// trigger the rest of the middleware stack
if ($this->resultSetCache->hasQuery($query)) {
return $this->resultSetCache->getFromQuery($query);
}
$finalResultSet = $next($query, $resultSet);
$this->resultSetCache->add($query, $finalResultSet);
return $finalResultSet;
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.