PHPackages                             simon80119/lumen-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. simon80119/lumen-geoip

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

simon80119/lumen-geoip
======================

GeoIP for Lumen

v3.0.0(8y ago)0155MITPHPPHP &gt;=5.5.9

Since Oct 13Pushed 6y agoCompare

[ Source](https://github.com/simon80119/lumen-geoip)[ Packagist](https://packagist.org/packages/simon80119/lumen-geoip)[ RSS](/packages/simon80119-lumen-geoip/feed)WikiDiscussions master Synced 2d ago

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

GeoIP for Lumen
===============

[](#geoip-for-lumen)

[![Latest Stable Version](https://camo.githubusercontent.com/f994f6e38c2010e05dd50b1a912700cd1bc7bdd634c0f1ed2e636bb43b707ac6/68747470733a2f2f706f7365722e707567782e6f72672f636f64652d6f72616e67652f6c756d656e2d67656f69702f762f737461626c65)](https://packagist.org/packages/code-orange/lumen-geoip) [![Total Downloads](https://camo.githubusercontent.com/492b703e32c1b4a15e3b96eddab6e07a10f96798a5633be3c2e5ec40164f526e/68747470733a2f2f706f7365722e707567782e6f72672f636f64652d6f72616e67652f6c756d656e2d67656f69702f646f776e6c6f616473)](https://packagist.org/packages/code-orange/lumen-geoip) [![License](https://camo.githubusercontent.com/41d885de1f21a0d16b92c5d0f09deea7f2391fdf364f5b7b9429b29a7fcd1e68/68747470733a2f2f706f7365722e707567782e6f72672f636f64652d6f72616e67652f6c756d656e2d67656f69702f6c6963656e7365)](https://packagist.org/packages/code-orange/lumen-geoip) [![composer.lock](https://camo.githubusercontent.com/9ed38bee1f6bf1e7fcfe5a84ad231c043e8cc406e9f61a5340025830e0e970cf/68747470733a2f2f706f7365722e707567782e6f72672f636f64652d6f72616e67652f6c756d656e2d67656f69702f636f6d706f7365726c6f636b)](https://packagist.org/packages/code-orange/lumen-geoip)

Determine the geographical location of website visitors based on their IP addresses.

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

[](#installation)

To install this package, just install through composer

```
$ composer require code-orange/lumen-geoip

```

### Providers

[](#providers)

Next, open `bootstrap/app.php` and add under the Register Service Providers section:

```
...
$app->register(CodeOrange\GeoIP\GeoIPServiceProvider::class);
```

### Update MaxMind GeoLite2 City database

[](#update-maxmind-geolite2-city-database)

Run this on the command line from the root of your project:

```
$ php artisan geoip:update

```

### Usage

[](#usage)

GeoIP will try to determine the IP using the following http headers: `HTTP_CLIENT_IP`, `HTTP_X_FORWARDED_FOR`, `HTTP_X_FORWARDED`, `HTTP_X_CLUSTER_CLIENT_IP`, `HTTP_FORWARDED_FOR`, `HTTP_FORWARDED`, `REMOTE_ADDR` in this order. Optionally you can set an IP as the only parameter to set it.

```
$record = app()->geoip->getLocation('232.223.11.11');
$record = GeoIP::getLocation('232.223.11.11'); // If you have enabled facades

print($record->country->isoCode . "\n"); // 'US'
print($record->country->name . "\n"); // 'United States'
print($record->country->names['zh-CN'] . "\n"); // '美国'

print($record->mostSpecificSubdivision->name . "\n"); // 'Minnesota'
print($record->mostSpecificSubdivision->isoCode . "\n"); // 'MN'

print($record->city->name . "\n"); // 'Minneapolis'

print($record->postal->code . "\n"); // '55455'

print($record->location->latitude . "\n"); // 44.9733
print($record->location->longitude . "\n"); // -93.2323
```

### Other Methods

[](#other-methods)

These methods are also available to use within your applications.

```
app()->geoip->checkIp($ip) // Checks IP to make sure IP is a valid IPv4 or IPv6 address and not within a private or reserved range
app()->geoip->getIp() // Returns the detected client IP
```

### Default Location Data

[](#default-location-data)

When an IP is not detected it will be set to 127.0.0.1 which will ultimately throw an Exception. If you are not in production your record will default to the following data.

```
array (
    "ip"           => "232.223.11.11",
    "isoCode"      => "US",
    "country"      => "United States",
    "city"         => "New Haven",
    "state"        => "CT",
    "postal_code"  => "06510",
    "lat"          => 41.28,
    "lon"          => -72.88,
    "timezone"     => "America/New_York",
    "continent"    => "NA",
    "default"      => false
);
```

Change Log
----------

[](#change-log)

#### v3.0.0

[](#v300)

- Added support for Lumen 5.5

#### v2.0.0

[](#v200)

- Simplified namespace
- Added Facade support
- Added default location when in development
- Fixed bug where detected IP was always blank

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 74.3% 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 ~154 days

Recently: every ~114 days

Total

6

Last Release

3094d ago

Major Versions

v1.0.0 → v2.0.0-RC2016-08-20

v2.0.2 → v3.0.02017-11-21

### Community

Maintainers

![](https://www.gravatar.com/avatar/72372ecc71a13998f83086ae3854aa2ec3b2644fadcc41aa476bbe3c7e88b2df?d=identicon)[simon801109](/maintainers/simon801109)

---

Top Contributors

[![cringerjs](https://avatars.githubusercontent.com/u/835448?v=4)](https://github.com/cringerjs "cringerjs (26 commits)")[![timvdalen](https://avatars.githubusercontent.com/u/1038428?v=4)](https://github.com/timvdalen "timvdalen (7 commits)")[![simon80119](https://avatars.githubusercontent.com/u/19222881?v=4)](https://github.com/simon80119 "simon80119 (2 commits)")

---

Tags

phpgeoiplumen

### Embed Badge

![Health badge](/badges/simon80119-lumen-geoip/health.svg)

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

###  Alternatives

[stevebauman/location

Retrieve a user's location by their IP Address

1.3k7.6M65](/packages/stevebauman-location)[kra8/laravel-snowflake

Snowflake for Laravel and Lumen.

188402.3k6](/packages/kra8-laravel-snowflake)[atchondjo/geoip2country

A lightweight but powerful IP address lookup database solution to determine visitors country

344.1k](/packages/atchondjo-geoip2country)

PHPackages © 2026

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