Hello Devs, 

In this tutorial, we will learn Laravel IP Address Using Get Location Example

Many times we need to get visitor's details for security, spam prevention, etc. It's very easy to get the visitor's IP address and their location in PHP Laravel.

Follow this step-by-step guide below. 

Step 1: Install stevebauman/location

composer require stevebauman/location

Step 2: Add providers and aliases


'providers' => [
'aliases' => [
  'Location' => Stevebauman\Location\Facades\Location::class,

Step 3:config with the publish command

php artisan vendor:publish --provider="Stevebauman\Location\LocationServiceProvider"

Step 4: Route routes/web.php


Step 5:Controller : app/Http/Controllers/LocationController.php

namespace App\Http\Controllers;
use Illuminate\Http\Request;

class LocationController extends Controller
  public function index(Request $request)
      $ip= $request->ip();
      $data = \Location::get($ip);

 run the below command for a quick run:

php artisan serve

open bellow URL on your browser:


May this example help you.