Skip to content

Drivers Overview ​

GeoIp uses a driver-based architecture. Each driver implements the ArielMejiaDev\GeoIp\Contracts\Driver interface and resolves IP addresses to geolocation data.

Available Drivers ​

DriverConfig ValueRequirementsRate Limit
DB-IP Litedbip (default)php artisan geo-ip:installNone (local)
MaxMindmaxmindLicense key + php artisan geo-ip:install --maxmindNone (local)
ip-apiip-apiNone45 req/min
ipinfoipinfoIPINFO_TOKENDepends on plan
NullnullNoneN/A

Switching Drivers ​

Set the GEOIP_DRIVER environment variable:

env
GEOIP_DRIVER=dbip

Or update config/geo-ip.php directly:

php
'driver' => 'maxmind',

At Runtime ​

You can also override the driver on the fly using the driver() method. See Runtime Driver for details.

php
GeoIp::driver('ip-api')->lookup('8.8.8.8');

Data Fields ​

All drivers return an IpData value object with these fields. Some fields may be null depending on the driver's capabilities:

FieldTypeDescription
ipstringThe queried IP address
countryCode?stringISO 3166-1 alpha-2 code (e.g., US)
country?stringFull country name
region?stringState or region name
city?stringCity name
latitude?floatGeographic latitude
longitude?floatGeographic longitude
timezone?stringIANA timezone (e.g., America/Los_Angeles)
isp?stringInternet service provider
postalCode?stringPostal / ZIP code

Null Driver ​

The null driver returns an IpData object with only the ip field populated. All other fields are null. Use it for testing:

env
GEOIP_DRIVER=null