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_ADDR
reliability)
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_ADDR
reliability)
You can use request object:
request()->server('SERVER_ADDR');
Or you can use standard PHP way:
$_SERVER['SERVER_ADDR'];
Request::server('SERVER_ADDR')
:)
URL Reference: https://laravel.com/api/5.3/Illuminate/Http/Request.html
$_SERVER['SERVER_ADDR']; for server ip
$_SERVER['SERVER_PORT']; for server port