Download the PHP package fyre/middleware without Composer
On this page you can find all versions of the php package fyre/middleware. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package middleware
FyreMiddleware
FyreMiddleware is a free, open-source middleware library for PHP.
Table Of Contents
- Installation
- Basic Usage
- Methods
- Middleware Queues
- Middleware
- Request Handlers
Installation
Using Composer
In PHP:
Basic Usage
$containeris a Container.
It is recommended to bind the MiddlewareRegistry to the Container as a singleton.
Any dependencies will be injected automatically when loading from the Container.
Methods
Clear
Clear all aliases and middleware.
Map
Map an alias to middleware.
$aliasis a string representing the middleware alias.$middlewareis a string representing the Middleware class.$argumentsis an array containing additional arguments for creating the Middleware, and will default to [].
Resolve
Resolve Middleware.
$middlewareis a Middleware class instance, class name, alias or Closure.
You can pass additional arguments to the handle method of the Middleware by appending a colon followed by a comma-separated list of arguments to the string.
Container.
Use
Load a shared Middleware instance.
$aliasis a string representing the middleware alias.
Container.
Middleware Queues
$middlewaresis an array containing the Middleware.
Add
Add Middleware.
$middlewareis a Closure.
Count
Get the Middleware count.
Current
Get the Middleware at the current index.
Insert At
Insert Middleware at a specified index.
$indexis a number representing the index.$middlewareis a Closure.
Key
Get the current index.
Next
Progress the index.
Prepend
Prepend Middleware.
$middlewareis a Closure.
Rewind
Reset the index.
Valid
Determine whether the current index is valid.
Middleware
Custom middleware can be created by extending \Fyre\Middleware\Middleware, ensuring all below methods are implemented.
Process
Process a ServerRequest.
$requestis a ServerRequest.$handleris a RequestHandler.
This method should call the handle method of the $handler with the $request, to handle the next middleware in the queue, then return the ClientResponse.
Closures
You can also provide custom middleware as a simple Closure.
Request Handlers
$containeris a Container.$middlewareRegistryis a MiddlewareRegistry.$queueis a MiddlewareQueue.$initialResponseis a ClientResponse to be used as the initial response, and will default to null.
Any dependencies will be injected automatically when loading from the Container.
If the $initialResponse is set to null, a new ClientResponse will be created.
Handle
Handle the next middleware in the queue.
$requestis a ServerRequest.
This method will return a ClientResponse.
The provided $request will be automatically set as the ServerRequest instance in the Container.
All versions of middleware with dependencies
fyre/macro Version ^2.0
fyre/server Version ^5.0
psr/http-server-handler Version ^1.0
psr/http-server-middleware Version ^1.0