I need to store the IP address of the users who comment, in the database after form submission.
Is there any symfony2 function to get the IP? Or any other way to get
FYI, As of Symfony 2.0 Request::getClientIp the $proxy parameter is deprecated. It will be removed in Symfony 2.3.
Request::getClientIp
$proxy
You can either use
$container->get('request')->server->get("REMOTE_ADDR");
or as @meze answer
$container->get('request')->getClientIp();