Download the PHP package jasny/dummy-middleware without Composer
On this page you can find all versions of the php package jasny/dummy-middleware. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jasny/dummy-middleware
More information about jasny/dummy-middleware
Files in jasny/dummy-middleware
Package dummy-middleware
Short Description Dummy client and server middleware for PSR-7 requests
License MIT
Informations about the package dummy-middleware
Jasny Dummy Middleware
Dummy client and server middleware for PSR-7 requests. Works both as PSR-15 and double pass middleware.
The dummy services work as null objects / passthrough, preventing the use of if's.
Installation
composer require jasny/dummy-middleware
Usage
Server middleware
Server middleware can be used all passthrough of PSR-7 server requests.
Single pass middleware (PSR-15)
The middleware implements the PSR-15 MiddlewareInterface
. As PSR standard many new libraries support this type of
middleware, for example Zend Stratigility.
Double pass middleware
Many PHP libraries support double pass middleware. These are callables with the following signature;
To get a callback to be used by libraries as Jasny Router and
Relay, use the asDoublePass()
method.
Client middleware
Client middleware can be used for PSR-7 compatible HTTP clients like Guzzle and HTTPlug.
Double pass middleware
The client middleware can be used by any client that does support double pass middleware. Such middleware are callables with the following signature;
Most HTTP clients do not support double pass middleware, but a type of single pass instead. However more general purpose PSR-7 middleware libraries, like Relay, do support double pass.
The client middleware does not conform to PSR-15 (single pass) as that is intended for server requests only.
Guzzle
Guzzle is the most popular HTTP Client for PHP. The middleware has a forGuzzle()
method
that creates a callback which can be used as Guzzle middleware.
HTTPlug
HTTPlug is the HTTP client of PHP-HTTP. It allows you to write reusable libraries and applications that need an HTTP client without binding to a specific implementation.
The forHttplug()
method for the middleware creates an object that can be used as HTTPlug plugin.