volmaticmw5 / ip2location
IP2location wrapper for laravel
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/volmaticmw5/ip2location
Requires
- php: >=7.4
- laravel/framework: ^6|^7|^8
This package is auto-updated.
Last update: 2026-01-13 00:02:34 UTC
README
A geo-ip ip2location wrapper for laravel
Instructions
In order to use this package, you'll need to download the ip2location databases from https://lite.ip2location.com/ip2location-lite .
After installing the package with composer, simply create a new instance of IP2Location and do whatever you need, e.g.:
use volmaticmw5\IP2Location\IP2Location; (...) $ip2location = new IP2Location(); $ip2location->Initialize('mysql', 'geoip_4', 'geoip_6');
Examples
Getting Geo-ip data from a request
$ip2location = new IP2Location(); $ip2location->Initialize('mysql', 'geoip_4', 'geoip_6'); $data = $ip2location->GetGeoDataFromRequest($request);
Getting country code from request
public function GetCountryCode() { $ip2location = new IP2Location(); $ip2location->Initialize('mysql', 'geoip_4', 'geoip_6'); $ipNum = $ip2location->getNumericIpFromClientRequest(); if($ip2location->isIpv6($ipNum)) return $ip2location->FromIpv6($ipNum); else return $ip2location->FromIpv4($ipNum); }