unil-lettres /
dilps-tiresias
| 1 | <?php |
||||
| 2 | |||||
| 3 | declare(strict_types=1); |
||||
| 4 | |||||
| 5 | use Application\Middleware\AuthenticationMiddleware; |
||||
| 6 | use Application\Middleware\RefreshSessionTimestampMiddleware; |
||||
| 7 | use Laminas\Stratigility\Middleware\ErrorHandler; |
||||
| 8 | use Mezzio\Application; |
||||
| 9 | use Mezzio\Handler\NotFoundHandler; |
||||
| 10 | use Mezzio\Helper\ServerUrlMiddleware; |
||||
| 11 | use Mezzio\Helper\UrlHelperMiddleware; |
||||
| 12 | use Mezzio\MiddlewareFactory; |
||||
| 13 | use Mezzio\Router\Middleware\DispatchMiddleware; |
||||
| 14 | use Mezzio\Router\Middleware\ImplicitHeadMiddleware; |
||||
| 15 | use Mezzio\Router\Middleware\ImplicitOptionsMiddleware; |
||||
| 16 | use Mezzio\Router\Middleware\RouteMiddleware; |
||||
| 17 | use Mezzio\Session\SessionMiddleware; |
||||
| 18 | use Psr\Container\ContainerInterface; |
||||
| 19 | |||||
| 20 | // Setup middleware pipeline: |
||||
| 21 | return function (Application $app, MiddlewareFactory $factory, ContainerInterface $container): void { |
||||
|
0 ignored issues
–
show
The parameter
$factory is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||
| 22 | // The error handler should be the first (most outer) middleware to catch |
||||
| 23 | // all Exceptions. |
||||
| 24 | $app->pipe(ErrorHandler::class); |
||||
| 25 | $app->pipe(ServerUrlMiddleware::class); |
||||
| 26 | |||||
| 27 | // Pipe more middleware here that you want to execute on every request: |
||||
| 28 | // - bootstrapping |
||||
| 29 | // - pre-conditions |
||||
| 30 | // - modifications to outgoing responses |
||||
| 31 | // |
||||
| 32 | // Piped Middleware may be either callables or service names. Middleware may |
||||
| 33 | // also be passed as an array; each item in the array must resolve to |
||||
| 34 | // middleware eventually (i.e., callable or service name). |
||||
| 35 | // |
||||
| 36 | // Middleware can be attached to specific paths, allowing you to mix and match |
||||
| 37 | // applications under a common domain. The handlers in each middleware |
||||
| 38 | // attached this way will see a URI with the matched path segment removed. |
||||
| 39 | // |
||||
| 40 | // - $app->pipe('/api', $apiMiddleware); |
||||
| 41 | // - $app->pipe('/docs', $apiDocMiddleware); |
||||
| 42 | // - $app->pipe('/files', $filesMiddleware); |
||||
| 43 | |||||
| 44 | // Register the routing middleware in the middleware pipeline. |
||||
| 45 | // This middleware registers the Mezzio\Router\RouteResult request attribute. |
||||
| 46 | $app->pipe(RouteMiddleware::class); |
||||
| 47 | $app->pipe(ImplicitHeadMiddleware::class); |
||||
| 48 | $app->pipe(ImplicitOptionsMiddleware::class); |
||||
| 49 | $app->pipe(UrlHelperMiddleware::class); |
||||
| 50 | $app->pipe(SessionMiddleware::class); |
||||
| 51 | $app->pipe(AuthenticationMiddleware::class); |
||||
| 52 | $app->pipe(RefreshSessionTimestampMiddleware::class); |
||||
| 53 | |||||
| 54 | // Add more middleware here that needs to introspect the routing results; this |
||||
| 55 | // might include: |
||||
| 56 | // |
||||
| 57 | // - route-based authentication |
||||
| 58 | // - route-based validation |
||||
| 59 | // - etc. |
||||
| 60 | |||||
| 61 | // Register the dispatch middleware in the middleware pipeline |
||||
| 62 | $app->pipe(DispatchMiddleware::class); |
||||
| 63 | |||||
| 64 | // At this point, if no Response is returned by any middleware, the |
||||
| 65 | // NotFoundHandler kicks in; alternately, you can provide other fallback |
||||
| 66 | // middleware to execute. |
||||
| 67 | $app->pipe(NotFoundHandler::class); |
||||
| 68 | }; |
||||
| 69 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.