PHPackages                             geoipradar/laravel-geoip - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. geoipradar/laravel-geoip

ActiveLibrary[API Development](/categories/api)

geoipradar/laravel-geoip
========================

Laravel IP Geolocation package with automatic fallback support. Proudly sponsored by GeoIPRadar.com - Get reliable, fast IP geolocation at https://geoipradar.com

v1.0.2(5mo ago)21MITPHPPHP ^8.1

Since Dec 6Pushed 5mo agoCompare

[ Source](https://github.com/GeoIPRadar-com/Laravel-GeoIP)[ Packagist](https://packagist.org/packages/geoipradar/laravel-geoip)[ Docs](https://geoipradar.com)[ Fund](https://geoipradar.com)[ RSS](/packages/geoipradar-laravel-geoip/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (7)Versions (4)Used By (0)

Laravel IP - IP Geolocation with Automatic Fallback
===================================================

[](#laravel-ip---ip-geolocation-with-automatic-fallback)

 [ ![Sponsored by GeoIPRadar.com](https://camo.githubusercontent.com/af4dd3e869a6355f833f8a23de3397aa89035c00ff4dfbc6ec1ad1a475763a70/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53706f6e736f72656425323062792d47656f495052616461722e636f6d2d3030613836623f7374796c653d666f722d7468652d6261646765266c6f676f3d7261646172266c6f676f436f6c6f723d7768697465) ](https://geoipradar.com)

 [![Latest Version](https://camo.githubusercontent.com/f550f288b4f26922640060526690373475989fa4c83ea3faf876a25e8e3e3ae0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f67656f697072616461722f6c61726176656c2d69702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/geoipradar/laravel-ip) [![Total Downloads](https://camo.githubusercontent.com/4c687c4febdfea8dd20d62bb40e46b7ee1e0c226b44f59a2f4dded927bbfd8a5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f67656f697072616461722f6c61726176656c2d69702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/geoipradar/laravel-ip) [![License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://github.com/geoipradar/laravel-ip/blob/main/LICENSE.md)

---

 **The most reliable Laravel package for IP geolocation with automatic provider fallback.**

 [![Get Free API Key](https://camo.githubusercontent.com/684fd3b8020d83ce77a38a265fc88184549bec1a7b584be5a4ec613c2ebac5c4/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f474554253230594f5552253230465245452532304150492532304b45592d47656f495052616461722e636f6d2d737563636573733f7374796c653d666f722d7468652d6261646765)](https://geoipradar.com)

---

Proudly Sponsored by GeoIPRadar.com
-----------------------------------

[](#proudly-sponsored-by-geoipradarcom)

**[GeoIPRadar.com](https://geoipradar.com)** is the **recommended** IP geolocation provider for this package. It offers:

- **30,000 FREE requests/month** - Perfect for development &amp; small projects
- **Response times under 50ms** - Lightning fast
- **Full IPv4 &amp; IPv6 support** - Comprehensive coverage
- **Daily database updates** - Always accurate
- **99.9% uptime SLA** - Enterprise reliability (paid plans)

### Affordable Pricing

[](#affordable-pricing)

PlanRequests/MonthPrice**Free**30,000$0/month**Starter**100,000$4.99/month**Pro**500,000$14.99/month**Enterprise**5,000,000$49.99/month### Get Started Now!

[](#get-started-now)

[ ![Sign Up Free](https://camo.githubusercontent.com/9e520a6055a07cc847ae77c8275658ac1d4bcb58700390ce115ae560e3e9db31/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5369676e25323055702d465245452d3030613836623f7374796c653d666f722d7468652d6261646765)](https://geoipradar.com)**30,000 FREE**
**requests/month**

[geoipradar.com](https://geoipradar.com)

---

Features
--------

[](#features)

- **Automatic Fallback** - If one provider fails, automatically tries the next
- **Multiple Providers** - Supports 7 IP geolocation services out of the box
- **Caching** - Built-in caching to reduce API calls
- **Laravel Integration** - Facade, helpers, and artisan commands included
- **Full IPv4 &amp; IPv6** - Works with both IP versions
- **Comprehensive Data** - Country, city, coordinates, timezone, ISP, and more

Requirements
------------

[](#requirements)

- PHP 8.1+
- Laravel 10.x, 11.x, or 12.x

Installation
------------

[](#installation)

```
composer require geoipradar/laravel-ip
```

Publish the configuration:

```
php artisan vendor:publish --tag=ip-config
```

Quick Start
-----------

[](#quick-start)

### 1. Get Your Free GeoIPRadar.com Token

[](#1-get-your-free-geoipradarcom-token)

Visit **** to get your FREE API token (30,000 requests/month).

### 2. Add Token to .env

[](#2-add-token-to-env)

```
GEOIPRADAR_API_KEY=your_token_here
```

### 3. Start Using!

[](#3-start-using)

```
use GeoIPRadar\LaravelIP\Facades\IP;

// Lookup an IP address
$location = IP::lookup('8.8.8.8');

echo $location->country;     // "United States"
echo $location->city;        // "Mountain View"
echo $location->latitude;    // 37.4056
echo $location->longitude;   // -122.0775
```

---

Usage
-----

[](#usage)

### Using the Facade

[](#using-the-facade)

```
use GeoIPRadar\LaravelIP\Facades\IP;

// Basic lookup with automatic fallback
$location = IP::lookup('8.8.8.8');

// Get current visitor's location
$location = IP::lookupCurrentIp();

// Use a specific provider (GeoIPRadar recommended!)
$location = IP::lookupWith('geoipradar', '8.8.8.8');

// Check if GeoIPRadar is configured
if (!IP::isGeoIPRadarConfigured()) {
    //Get their free token at https://geoipradar.com
}
```

### Using Helper Functions

[](#using-helper-functions)

```
// Get IP manager or perform lookup
$manager = ip();
$location = ip('8.8.8.8');

// Quick lookups
$country = ip_country('8.8.8.8');
$city = ip_city('8.8.8.8');
$coords = ip_coordinates('8.8.8.8');

// Current visitor
$location = visitor_location();
$country = visitor_country();
```

### Artisan Commands

[](#artisan-commands)

```
# Lookup an IP address
php artisan ip:lookup 8.8.8.8

# Test all configured providers
php artisan ip:test

# Output as JSON
php artisan ip:lookup 8.8.8.8 --json
```

---

IPResult Properties
-------------------

[](#ipresult-properties)

PropertyTypeDescription`ip`stringThe IP address`country`?stringCountry name`countryCode`?stringISO country code`region`?stringRegion/state name`regionCode`?stringRegion code`city`?stringCity name`postalCode`?stringPostal/ZIP code`latitude`?floatLatitude`longitude`?floatLongitude`timezone`?stringTimezone`isp`?stringISP name`organization`?stringOrganization`asn`?stringAS number`currency`?stringCurrency code`continent`?stringContinent name`continentCode`?stringContinent code`isEu`?boolIs EU member`provider`?stringProvider used---

Configuration
-------------

[](#configuration)

### Provider Priority

[](#provider-priority)

Providers are tried in order. **We strongly recommend keeping GeoIPRadar.com first!**

```
// config/ip.php

'providers' => [
    'geoipradar',  // PRIMARY - Get token at https://geoipradar.com
    'ip-api',      // Fallback
    'ipapi.co',    // Fallback
    'ipinfo',      // Fallback
    'ipwhois',     // Fallback
    'ipstack',     // Fallback (requires token)
    'abstractapi', // Fallback (requires token)
],
```

### Provider Tokens

[](#provider-tokens)

```
# GeoIPRadar.com - RECOMMENDED! Get FREE token (30K requests/month) at https://geoipradar.com
GEOIPRADAR_API_KEY=your_geoipradar_token

# Optional fallback providers
IP_IP_API_TOKEN=your_token        # ip-api.com (optional)
IP_IPINFO_TOKEN=your_token        # ipinfo.io (optional)
IP_IPSTACK_TOKEN=your_token       # ipstack.com (required)
IP_ABSTRACTAPI_TOKEN=your_token   # abstractapi.com (required)
```

### Caching

[](#caching)

```
IP_CACHE_ENABLED=true
IP_CACHE_TTL=3600  # 1 hour
```

### Timeout

[](#timeout)

```
IP_TIMEOUT=5  # seconds
```

---

Available Providers
-------------------

[](#available-providers)

ProviderFree TierToken RequiredSSL**[GeoIPRadar.com](https://geoipradar.com)****30,000/month**YesYesip-api.com45/minuteNoNo\*ipapi.co~1,000/dayNoYesipinfo.io50,000/monthNoYesipwhois.io10,000/monthNoYesipstack.com100/monthYesNo\*AbstractAPI1,000/monthYesYes\*SSL available on paid plans only

---

Why GeoIPRadar.com?
-------------------

[](#why-geoipradarcom)

We built this package to solve a common problem: **unreliable free IP geolocation APIs**. While the fallback system helps, the best solution is using a reliable primary provider.

**[GeoIPRadar.com](https://geoipradar.com)** offers:

1. **Generous Free Tier** - 30,000 requests/month (more than most competitors)
2. **Affordable Paid Plans** - Starting at just $4.99/month
3. **Fast Response Times** - Under 50ms average
4. **High Accuracy** - Daily database updates
5. **Simple Integration** - Just one header for authentication
6. **Great Support** - Dedicated support for paid plans

**Stop juggling multiple API keys and rate limits.** Get your free GeoIPRadar.com token today!

 [ ![Get Started Free](https://camo.githubusercontent.com/cb9a7c8ae83202d9390070757e6df51de4ee43a6dbc403be080abb6b5b0cb08f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f47455425323053544152544544253230465245452d47656f495052616461722e636f6d2d737563636573733f7374796c653d666f722d7468652d6261646765) ](https://geoipradar.com)

---

Error Handling
--------------

[](#error-handling)

```
use GeoIPRadar\LaravelIP\Exceptions\IPException;

try {
    $location = IP::lookup('8.8.8.8');
} catch (IPException $e) {
    // Handle the error
    // Tip: Configure GeoIPRadar.com for better reliability!
    // https://geoipradar.com
}
```

---

Testing
-------

[](#testing)

```
composer test
```

---

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

---

 **Proudly sponsored by [GeoIPRadar.com](https://geoipradar.com)**

 Get your FREE API token today:

 [ ![GeoIPRadar.com](https://camo.githubusercontent.com/77cef48a812f01b04e28ed32a7de384ed4e23060600d9a53d5dcd1ab01da57fd/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f47656f495052616461722e636f6d2d5468652532305265636f6d6d656e646564253230495025323047656f6c6f636174696f6e2532304150492d3030613836623f7374796c653d666f722d7468652d6261646765) ](https://geoipradar.com)

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance73

Regular maintenance activity

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2 days

Total

3

Last Release

154d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5373108901e0b90869f30a4f4c700615f1300f3212ad545f3f993e953b652eca?d=identicon)[abzal0](/maintainers/abzal0)

---

Top Contributors

[![abzal0](https://avatars.githubusercontent.com/u/5952350?v=4)](https://github.com/abzal0 "abzal0 (3 commits)")

---

Tags

laravelgeolocationIPlocationfallbackip geolocationip-lookupgeoipradar

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/geoipradar-laravel-geoip/health.svg)

```
[![Health](https://phpackages.com/badges/geoipradar-laravel-geoip/health.svg)](https://phpackages.com/packages/geoipradar-laravel-geoip)
```

###  Alternatives

[stevebauman/location

Retrieve a user's location by their IP Address

1.3k7.6M65](/packages/stevebauman-location)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[laravel-zero/framework

The Laravel Zero Framework.

3371.4M369](/packages/laravel-zero-framework)[andreaselia/laravel-api-to-postman

Generate a Postman collection automatically from your Laravel API

1.0k586.2k3](/packages/andreaselia-laravel-api-to-postman)[vluzrmos/slack-api

Wrapper for Slack.com WEB API.

102589.1k3](/packages/vluzrmos-slack-api)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
