Download the PHP package oscarotero/middleland without Composer
On this page you can find all versions of the php package oscarotero/middleland. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download oscarotero/middleland
More information about oscarotero/middleland
Files in oscarotero/middleland
Package middleland
Short Description PSR-15 middleware dispatcher
License MIT
Homepage https://github.com/oscarotero/dispatcher
Informations about the package middleland
Middleland
Simple (but powerful) PSR-15 middleware dispatcher:
Requirements
- PHP 7
- A PSR-7 Message implementation, for example laminas-diactoros
- Optionally, a PSR-11 container implementation to create the middleware components on demand.
Example
Matchers
As you can see in the example above, you can use an array of "matchers" to
filter the requests that receive middlewares. You can use callables, instances
of Middleland\Matchers\MatcherInterface
or booleans, but for comodity, the
string values are also used to create Middleland\Matchers\Path
instances. The
available matchers are:
Name | Description | Example |
---|---|---|
Path |
Filter requests by base path. Use exclamation mark for negative matches | new Path('/admin') , new Path('!/not-admin') |
Pattern |
Filter requests by path pattern. Use exclamation mark for negative matches | new Pattern('*.png') new Pattern('!*.jpg') |
Accept |
Filter requests by Accept header. Use exclamation mark for negative matches | new Accept('text/html') new Accept('!image/png') |
How to create matchers
Just use a callable or an instance of the
Middleland\Matchers\MatcherInterface
. Example:
Please see CHANGELOG for more information about recent changes.
The MIT License (MIT). Please see LICENSE for more information.