Download the PHP package appertly/ducts without Composer
On this page you can find all versions of the php package appertly/ducts. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download appertly/ducts
More information about appertly/ducts
Files in appertly/ducts
Package ducts
Short Description A PSR-7 compliant middleware dispatcher for Hack/HHVM
License MIT
Homepage https://github.com/appertly/ducts
Informations about the package ducts
ducts
A PSR-7 compliant middleware dispatcher for Hack/HHVM.
It's the same idea as Connect, Relay, Stratigility, Middleman, etc., but in strict mode Hack.
Installation
You can install this library using Composer:
- The master branch (version 0.x) of this project requires HHVM 3.12 and has no dependencies.
Compliance
Releases of this library will conform to Semantic Versioning.
Our code is intended to comply with PSR-1, PSR-2, and PSR-4. If you find any issues related to standards compliance, please send a pull request!
Layers and Dispatching
The idea here is that you supply a list of functions which:
- Accept a request, a response, and a next function
- Possibly modify the request and response
- Possibly invoke the next function, which returns a response
- Possibly modify the returned response
- Return the response
Layers end up interacting like this:
- → First layer
- → Second layer
- → Third layer
- ← Third layer
- ← Second layer
- ← First layer
Dispatch a Request
You can also make use of the ResolvingRunner if you'd like to look up the layer callable.
A Runner as a Layer
You can use a Runner as a layer by calling $runner->layer()!
For example, you declare Runner $bar to be the second layer of three in Runner $foo.
If $bar has three layers, it will participate in $foo like this:
- →
$foolayer 1- →
$barlayer 1 - →
$barlayer 2- →
$barlayer 3 - →
$foolayer 3 - ←
$foolayer 3 - ←
$barlayer 3
- →
- ←
$barlayer 2 - ←
$barlayer 1
- →
- ←
$foolayer 1