how to access server variables

29 views
Skip to first unread message

Pedro Ponte

unread,
Nov 12, 2021, 1:45:17 PM11/12/21
to Fusio
Hi there,

can you help detailing how to access these variables?

PHP SERVER 'HTTP_CLIENT_IP', HTTP_X_FORWARDED_FOR, REMOTE_ADDR?
Also, is it possible to do a var dump with fusio?

Tried dumping (print_r/var_dump)variables \Fusio\Engine\RequestInterface $request and $request->getBody() without success.

Many thanks

Christoph Kappestein

unread,
Nov 12, 2021, 4:12:11 PM11/12/21
to Fusio
Hi,

so you can use the $request->getHeader() method to obtain HTTP headers see also our documentation:

otherwise you can of course also use the PHP $_SERVER globals but it is recommended to use the request object to get information about the current request.
Regarding var_dump, you can also simply put a variable to the response to see the actual value, since if you use var_dump this will corrupt the JSON output.

best regards
Christoph

Pedro Ponte

unread,
Nov 12, 2021, 4:23:08 PM11/12/21
to Fusio
Thanks.
I've tried using $request->getHeader() before but can's seem to find the parameter that would return the origin IP address.
The docs here also don't mention anything.
I have tried with HTTP_X_FORWARDED_FOR etc but no luck. Any hint please?

Christoph Kappestein

unread,
Nov 12, 2021, 5:17:26 PM11/12/21
to Fusio
So you could also try to return the result of ->getHeaders() as response to see which headers are available,
normally all HTTP_* headers should be available.

best regards
Christoph
Reply all
Reply to author
Forward
0 new messages