0

I used symfony 1.4 to create my application.

I'd like to get the IP adress of the current server to put it within soap request

So, how can i get the IP address of the current server?

Cœur
  • 34,719
  • 24
  • 185
  • 251
BenGamra
  • 459
  • 4
  • 17
  • This is not a Symfony related question, please check this answers about getting the server IP on PHP: http://stackoverflow.com/questions/5800927/how-to-identify-server-ip-address-in-php – nikoskip Jul 29 '16 at 18:28
  • 1
    It depends if they need to get the IP address using the framework. It is not recommanded to use globals for example – sinhix Aug 26 '16 at 12:03

2 Answers2

3

For most situations, using $_SERVER['SERVER_ADDR']; will work. If that doesn't work you can try $ip = gethostbyname(gethostname());

Kris Peeling
  • 990
  • 7
  • 18
0

If you have access to the $request object and it is a sfWebRequest (typical request from a browser) you can use:

$request->getPathInfoArray()['SERVER_ADDR']
sinhix
  • 828
  • 6
  • 11