PHP code example of willy68 / pg-middleware-stack

1. Go to this page and download the library: Download willy68/pg-middleware-stack 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/ */

    

willy68 / pg-middleware-stack example snippets


use Pg\Middleware\Stack\MiddlewareAwareStackTrait;

class MyMiddlewareStack
{
    use MiddlewareAwareStackTrait;
}

$stack = new MyMiddlewareStack();
$stack->middleware($monMiddleware);
$stack->middlewares([$middleware1, $middleware2]);
$stack->prependMiddleware($middlewarePrioritaire);

$middleware = $stack->shiftMiddleware($container);
if ($middleware) {
    // Exécuter le middleware
}