Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the server IP with Laravel

Tags:

laravel

Using Laravel, I can get the client IP with request()->ip().

Is there a Laravel built-in way to get the server IP? Or is it something "impossible" (same problem as SERVER_ADDRreliability)

like image 965
rap-2-h Avatar asked Dec 21 '16 08:12

rap-2-h


2 Answers

You can use request object:

request()->server('SERVER_ADDR');

Or you can use standard PHP way:

$_SERVER['SERVER_ADDR'];
like image 134
Alexey Mezenin Avatar answered Sep 28 '22 04:09

Alexey Mezenin


Request::server('SERVER_ADDR') :)

URL Reference: https://laravel.com/api/5.3/Illuminate/Http/Request.html

like image 24
Imam Assidiqqi Avatar answered Sep 28 '22 05:09

Imam Assidiqqi