$request = Request::createFromGlobals(); $clientIp = $request->getClientIp();
if ($form->isSubmitted() && $form->isValid()) { $request = Request::createFromGlobals(); $formData = $form->getData(); $ipAddress = $request->getClientIp(); // save $formData & $ipAddress to database or log file }In both examples, we are using the getClientIp method to get the IP address of the client from the request object. The method will return the most reliable IP address for the client, taking into consideration the various ways that clients may be connecting to your application. Package library: Symfony HTTP foundation.