New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

salmaabdelhady/lumen-geoip

GeoIP for Lumen
117

Larablocks Analysis

salmaabdelhady/lumen-geoip works with Laravel 5 (latest release 2.0.3, Apr 12, 2018), which reached end of life: no more fixes, even for security.

Recommendation checks

Not advised

Not advised: no release or commit in over 2 years.

  • No release or commit in over 2 years
  • Supports only Laravel 5, past end of life
  • No release in the last 12 months (last: Apr 12, 2018)
  • 0 downloads a month (needs 10,000)
  • 0 GitHub stars (needs 100)

State

Likely abandoned
  • No release or commit in over 2 years.
  • Last stable release: Apr 12, 2018.
  • No releases in the last 12 months.
  • First released: Oct 13, 2015.
  • 0 open issues on GitHub.

Data from Packagist and GitHub, checked by Larablocks on Nov 28, 2026.

Install
composer require salmaabdelhady/lumen-geoip
Latest Version:2.0.3
PHP:>=7.0
Laravel:5
License:MIT
Last Updated:Apr 12, 2018
Links: GitHub  ·  Packagist
Maintainer: SalmaAbdelhady

GeoIP for Lumen

Latest Stable Version Total Downloads Latest Unstable Version License

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

Installation

To install this package, just install through composer

$ composer require salmaabdelhady/lumen-geoip

Providers

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

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

Update MaxMind GeoLite2 City database

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

$ php artisan geoip:update

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

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

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

v2.0.0
  • Simplified namespace
  • Added Facade support
  • Added default location when in development
  • Fixed bug where detected IP was always blank

Related Packages

rajeevsiewnath/lumen-react

Resource binding for easy model/resource maintainence

215
dusterio/lumen-passport

Making Laravel Passport work with Lumen

1,316,105 649
ersoy-insider/newrelic-custom-event

Sends custom events to newrelic insights

32,365 1
nomadnt/lumen-passport

Lumen porting of Laravel Passport

9,502 4
samfrm/lumen-passport

Making Laravel Passport work with Lumen

763 2

Version History

Version Released PHP Laravel License
2.0.3 >=7.0 ^5.6 MIT
v2.0.2 >=5.5.9 MIT
v2.0.1 >=5.5.9 MIT
v2.0.0 >=5.5.9 MIT
v1.0.0 >=5.5.9 MIT
Pre-releases (1)
Version Released PHP License
v2.0.0-RC >=5.5.9 MIT