PHPackages                             reefki/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. reefki/laravel-geoip

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

reefki/laravel-geoip
====================

A Laravel package to get IP addresses geographical location.

v2.0.0(5mo ago)20622↓100%MITPHPPHP ^8.1CI passing

Since Oct 8Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/reefki/laravel-geoip)[ Packagist](https://packagist.org/packages/reefki/laravel-geoip)[ RSS](/packages/reefki-laravel-geoip/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (9)Versions (3)Used By (0)

Laravel GeoIP
=============

[](#laravel-geoip)

[![tests](https://github.com/reefki/laravel-geoip/actions/workflows/tests.yml/badge.svg)](https://github.com/reefki/laravel-geoip/actions/workflows/tests.yml)

A Laravel package to get geographical location information from IP addresses.

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

[](#requirements)

- PHP 8.1 or higher
- Laravel 10, 11, or 12

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

[](#installation)

Install the package via Composer:

```
composer require reefki/laravel-geoip
```

Optionally, publish the config file:

```
php artisan vendor:publish --provider="Reefki\Geoip\GeoipServiceProvider" --tag="config"
```

Usage
-----

[](#usage)

### Using the Facade

[](#using-the-facade)

```
use Reefki\Geoip\Geoip;

$geoip = Geoip::get('8.8.8.8');

$geoip->driver;         // geojs
$geoip->ip;             // 8.8.8.8
$geoip->city;           // Mountain View
$geoip->region;         // California
$geoip->country;        // United States
$geoip->country_code;   // US
$geoip->continent_code; // NA
$geoip->timezone;       // America/Los_Angeles
$geoip->latitude;       // 37.751
$geoip->longitude;      // -97.822
$geoip->cached;         // true or false
```

IPv6 addresses are also supported:

```
$geoip = Geoip::get('2001:4860:4860::8888');
```

### Disabling Cache

[](#disabling-cache)

By default, results are cached. To get realtime data:

```
Geoip::get('8.8.8.8', cache: false);
```

### Using with Request

[](#using-with-request)

Get GeoIP data for the current request's IP address:

```
$geoip = $request->geoip();
```

With anonymized IP (for GDPR compliance):

```
$geoip = $request->geoip(anonymize: true);
```

Get just the anonymized IP address:

```
$anonymizedIp = $request->anonymizedIp();
// 8.8.8.8 → 8.8.8.0
// 2001:4860:4860::8888 → 2001:4860:4860::
```

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

[](#configuration)

### Default Driver

[](#default-driver)

Set the default driver in your `.env` file:

```
GEOIP_DEFAULT_DRIVER=geojs

```

### Cache Settings

[](#cache-settings)

Configure caching behavior:

```
GEOIP_CACHE_STORE=redis
GEOIP_CACHE_TTL=86400

```

### HTTP Settings

[](#http-settings)

Configure timeout and retry for API requests:

```
GEOIP_TIMEOUT=10
GEOIP_RETRY=3

```

Drivers
-------

[](#drivers)

### GeoJS (Default)

[](#geojs-default)

[GeoJS](https://www.geojs.io) is a free service with no API key required.

```
Geoip::driver('geojs')->get('8.8.8.8');
```

### IPData

[](#ipdata)

[IPData](https://ipdata.co) requires an API key. [Register](https://dashboard.ipdata.co/sign-up.html) for an account and add your key to `.env`:

```
IPDATA_API_KEY=your_api_key

```

Then use the driver:

```
Geoip::driver('ip-data')->get('8.8.8.8');
```

> **Note:** IPData offers 1,500 free requests per day. Higher usage requires a paid plan.

Testing
-------

[](#testing)

```
vendor/bin/phpunit
```

Credits
-------

[](#credits)

- [Rifki Aria Gumelar](https://github.com/reefki)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance73

Regular maintenance activity

Popularity22

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

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 ~792 days

Total

2

Last Release

155d ago

Major Versions

v1.0.0 → v2.0.02025-12-09

### Community

Maintainers

![](https://www.gravatar.com/avatar/763a069dcd1da9282ad845226c622ccdc4ad6385560903e20ad751cbbdb1b97e?d=identicon)[reefki](/maintainers/reefki)

---

Top Contributors

[![reefki](https://avatars.githubusercontent.com/u/10998084?v=4)](https://github.com/reefki "reefki (6 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[spatie/laravel-export

Create a static site bundle from a Laravel app

646127.9k5](/packages/spatie-laravel-export)[illuminate/session

The Illuminate Session package.

9937.4M753](/packages/illuminate-session)[glhd/conveyor-belt

14797.0k](/packages/glhd-conveyor-belt)[aedart/athenaeum

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

245.2k](/packages/aedart-athenaeum)[ashallendesign/favicon-fetcher

A Laravel package for fetching website's favicons.

190272.4k3](/packages/ashallendesign-favicon-fetcher)[beyondcode/laravel-favicon

Create dynamic favicons based on your environment settings.

37345.5k](/packages/beyondcode-laravel-favicon)

PHPackages © 2026

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