Esc
API Index — Namespaces, Packages, Reports, Indices
RequestHeaderMiddleware
in package
implements
MiddlewareInterface
Request Header Middleware — Apache mod_headers RequestHeader parity.
Manipulates the request headers the application sees, before handlers run.
Headers are written into $g->server using the mod_php CGI convention
(HTTP_<NAME>, uppercased, dashes → underscores), so apache_request_headers(),
getallheaders(), and $g->server['HTTP_*'] reflect the change — the same
place mod_php exposes inbound headers.
Operations (Apache RequestHeader <op> Name [value]):
set— replace (or create) the headerappend/add— append to the existing value (comma-joined) or createunset— remove the header
Usage in app.php:
$app->addMiddleware(new \ZealPHP\Middleware\RequestHeaderMiddleware([
['op' => 'set', 'name' => 'X-Forwarded-Proto', 'value' => 'https'],
['op' => 'unset', 'name' => 'X-Debug'],
]));
Table of Contents
Interfaces
- MiddlewareInterface
Properties
- $rules : array<int, array{op: string, name: string, value: string}>
Methods
- __construct() : mixed
- process() : ResponseInterface
Properties
$rules
private
array<int, array{op: string, name: string, value: string}>
$rules
= []
Methods
__construct()
public
__construct(array<int, array<string, mixed>> $rules) : mixed
Parameters
- $rules : array<int, array<string, mixed>>
-
Each:
op(set|append|add|unset),name(header name),value(required except for unset).
process()
public
process(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterface
Parameters
- $request : ServerRequestInterface
- $handler : RequestHandlerInterface