1. Go to this page and download the library: Download petrgrishin/pipe 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/ */
petrgrishin / pipe example snippets
use PetrGrishin\Pipe\Pipe;
// Class name
$accessFiltres = [
AccessFilterMiddleware::class,
];
// Or class name with constructor arguments
$accessFiltres = [
[AccessFilterMiddleware::class, $paramMiddleware],
];
// Or closure function
$accessFiltres = [
function (Request $request, Responce $response, Closure $next) {
return $next($request, $response);
}
];
// Start the process
Pipe::create($request, $response)
->through($accessFiltres)
->through($XSSFiltres)
->then(function (Request $request, Responce $response) {
$response->runController($request);
});
class AccessFilterMiddleware {
protected $paramMiddleware;
public function __construct($paramMiddleware = null) {
$this->paramMiddleware = $paramMiddleware;
}
public function __invoke(Request $request, Responce $response, Closure $next) {
if ($request->isPost()) {
$response->addError('Post is forbidden');
return false;
}
return $next($request, $response);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.