Download the PHP package krak/mw-http without Composer
On this page you can find all versions of the php package krak/mw-http. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package mw-http
Short Description Http Middlewares and Application
License
Homepage https://gitlab.bighead.net/krak-mw/http
Informations about the package mw-http
Http
The Krak Http package is a set of utilities for building Http applications. It comes with an implementation agnostic routing system, PSR-7 Response Factories, PSR-7 Server implementation, and a handful of useful middleware for Http applications.
Installation
Install via composer at krak/http
Usage
Response Factories
Every response factory must implement that interface.
Routes
Compiling Routes
Once you've created a set of routes, you can then compile them with a route compiler. These will traverse the hierarchy of routes and flatten them into an iterator with normalized paths.
Dispatch
To dispatch a set of routes, you need to create dispatcher factory, which will create a dispatcher from a set of routes, then you can dispatch a PSR-7 request.
Server
The server is responsible for creating a request, and emitting a response. It's a simple interface:
Middleware
Here are several useful middleware to use within your own applications. Each middleware takes two arguments: A PSR-7 Server Request, and an HttpLink. If you want more documentation on how the Link's work, checkout the Krak\Mw library.
injectRequestAttribute($name, $value)
This will automatically inject an attribute with a name and the given value.
wrap($psr7_middleware)
This will wrap PSR-7 style middleware that use the request and response in the middleware parameters.
serveStatic($root)
This will sit and will check if a file exists at the URI path. If it does, it will serve the file, else it will fall through to the next middleware.
mount($path, $mw)
Mounts a middleware on a path prefix. If the path prefix is matched, then the middleware is invoked.
The above middleware will try to load files on the /assets
uri. So GET /assets/app.css
will return a css file content if __DIR__ . /path/to/assets/app.css
exists in the filesystem.
Tests and Examples
Run tests via:
All versions of mw-http with dependencies
krak/mw Version ^0.5.0
nikic/fast-route Version ^1.0
nikic/iter Version ^1.4
pimple/pimple Version ^3.0
zendframework/zend-diactoros Version ^1.3