The best way to retrieve the current IP address of the client is via middleware using a component such as rka-ip-address-middleware.
This component can be installed via composer:
To use it, register the middleware with the
App, providing a list of trusted proxies (e.g. varnish servers) if you are using them.:
The middleware stores the client’s IP address in a request attribute, so access is via