Download the PHP package reindeer/symfony-middleware without Composer
On this page you can find all versions of the php package reindeer/symfony-middleware. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download reindeer/symfony-middleware
More information about reindeer/symfony-middleware
Files in reindeer/symfony-middleware
Package symfony-middleware
Short Description Middleware support for symfony
License MIT
Informations about the package symfony-middleware
Symfony middleware
Introduction
This bundle provides PSR-15-like middlewares in Symfony. Unlike PSR-15 it uses common Symfony Requests and Responses.
Installation
Usage
Each middleware must implement the Reindeer\SymfonyMiddleware\Contracts\MiddlewareInterface
.
This interface is very similar to Psr\Http\Server\MiddlewareInterface
but uses Symfony\Component\HttpFoundation\Request
and Symfony\Component\HttpFoundation\Response
instead of
Psr\Http\Message\RequestInterface
and Psr\Http\Message\ResponseInterface
respectively.
Some middleware for a route can be applied using options array in route description.
Protect route with a middleware
Let's create a middleware which authentication checks:
src/Middleware/AuthMiddleware.php
Now we need to protect the route using our middleware:
config/routes.yaml
That's all.
You can add as much middlewares for every route as you need.
Please note: if you use import routes and set middlewares both in routes and collection only collection middlewares are used.
config/imported-routes.yaml
config/routes.yaml
Examples
Before middleware to check authentication
After middleware to send logs to external service
License
All versions of symfony-middleware with dependencies
symfony/config Version >=5.3
symfony/dependency-injection Version >=5.3
symfony/http-kernel Version >=5.3
symfony/routing Version >=5.3