PHP code example of cocoon-projet / pipe
1. Go to this page and download the library: Download cocoon-projet/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/ */
cocoon-projet / pipe example snippets
use Cocoon\Pipe\Pipe;
use Laminas\Diactoros\ServerRequestFactory;
use function Http\Response\send;
$request = ServerRequestFactory::fromGlobals(
$_SERVER,
$_GET,
$_POST,
$_COOKIE,
$_FILES
);
$pipe = new Pipe();
$pipe->add(\Middlewares\Whoops::class);
$pipe->add(\App\Middlewares\Router::class);
// vous pouvez aussi instancier le middleware en amont
// $pipe->add(new MyMiddelware());
// ou ajouter les middlewares avec un array
// $pipe->add([\Middlewares\Whoops::class,
// \App\Middlewares\Router::class]
// );
$response = $pipe->handle($request);
send($response);