Download the PHP package luisinder/remote-port-middleware without Composer
On this page you can find all versions of the php package luisinder/remote-port-middleware. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download luisinder/remote-port-middleware
More information about luisinder/remote-port-middleware
Files in luisinder/remote-port-middleware
Package remote-port-middleware
Short Description PSR-7 / PSR-15 middleware that determines the client remote TCP port and stores it as a ServerRequest attribute (remotePort). Compatible with Slim 3 (legacy) & Slim 4+.
License BSD-3-Clause
Homepage https://github.com/lcajigasm/remote-port-middleware
Informations about the package remote-port-middleware
Remote Port Middleware
PSR-7 / PSR-15 middleware that determines the client's remote TCP port (from the REMOTE_PORT server param) and stores it as a ServerRequest attribute named remotePort.
Works with:
- Slim 4+ (PSR-15 single-pass)
- Slim 3 (legacy double-pass) – still supported for backwards compatibility
- Any PSR-15 compatible framework (Mezzio, etc.)
Requirements
- PHP >= 8.0
- psr/http-message ^1.0 || ^2.0
- psr/http-server-middleware ^1.0
Installation
How it works
On each request the middleware inspects $request->getServerParams()['REMOTE_PORT'] (if present) and attaches it to the request as remotePort (integer or null if missing).
Usage (Slim 4+)
Container registration (optional)
If you prefer adding via DI container (e.g. using PHP-DI):
Usage (Slim 3 legacy)
Attribute name
The attribute key is remotePort. Example:
Error handling & edge cases
If REMOTE_PORT is missing the attribute value will be null.
Testing
You can simulate a request by constructing a PSR-7 ServerRequest with a custom server params array:
Contributing
PRs and issues are welcome. Please include tests where possible.
License
BSD-3-Clause. See the LICENSE file for details.
All versions of remote-port-middleware with dependencies
psr/http-message Version ^1.0 || ^2.0
psr/http-server-middleware Version ^1.0