Download the PHP package ellipse/middleware-container without Composer
On this page you can find all versions of the php package ellipse/middleware-container. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ellipse/middleware-container
More information about ellipse/middleware-container
Files in ellipse/middleware-container
Package middleware-container
Short Description Psr-15 middleware proxying a Psr-11 container entry
License MIT
Homepage https://github.com/ellipsephp/middleware-container
Informations about the package middleware-container
Middleware container
This package provides a Psr-15 middleware proxying a Psr-11 container entry.
Require php >= 7.0
Installation composer require ellipse/middleware-container
Run tests ./vendor/bin/kahlan
- Using container entries as middleware
- Example using auto wiring
Using container entries as middleware
The class Ellipse\Middleware\ContainerMiddleware
takes an implementation of Psr\Container\ContainerInterface
and a container id as parameters. Its ->process()
method retrieve a middleware from the container using this id and proxy its ->process()
method.
It can be useful in situations the container entry should be resolved at the time the request is processed.
An Ellipse\Middleware\Exceptions\ContainedMiddlewareTypeException
is thrown when the value retrieved from the container is not an object implementing Psr\Http\Server\MiddlewareInterface
.
Example using auto wiring
It can be cumbersome to register every middleware classes in the container. Here is how to auto wire middleware instances using the Ellipse\Container\ReflectionContainer
class from the ellipse/container-reflection package.
All versions of middleware-container with dependencies
psr/http-message Version ^1.0
psr/http-server-handler Version ^1.0
psr/http-server-middleware Version ^1.0
psr/container Version ^1.0
ellipse/type-errors Version ^1.0