In this article, I will share with you how to get IP address in your Laravel 8 application with several way examples. in many application you need to get user ip address in laravel application. so, here i share with you some simple example how to get ip address in laravel application.
In laravel application, you can get IP address using Request ip, Request getClientIp and request helper function.
Example - 1
$clientIP = request()->ip();
dd($clientIP);
Example - 2
public function index(Request $request)
{
dd($request->ip());
}
Example - 3
$clientIP = \Request::ip();
dd($clientIP)
Example - 4
$clientIP = \Request::getClientIp(true);
dd($clientIP);
i hope it will help you lot.