PSR-7 Middleware that determines the client remote port and stores it as an ServerRequest
attribute called remotePort
.
composer require luisinder/remote-port-middleware
In Slim 3:
$app->add(new Luisinder\Middleware\RemotePort());
$app->get('/', function ($request, $response, $args) {
$remotePort = $request->getAttribute('remotePort');
return $response;
});