Skip to content

Add ip2geo driver#83

Open
bfzli wants to merge 1 commit into
pulkitjalan:mainfrom
bfzli:add-ip2geo-driver
Open

Add ip2geo driver#83
bfzli wants to merge 1 commit into
pulkitjalan:mainfrom
bfzli:add-ip2geo-driver

Conversation

@bfzli
Copy link
Copy Markdown

@bfzli bfzli commented Apr 20, 2026

Summary

Adds a new driver for the ip2geo IP geolocation API.

  • Supports IPv4 and IPv6 address lookup
  • Returns all standard fields: city, country, countryCode, latitude, longitude, region, regionCode, timezone, postalCode
  • Full raw API response available via getRaw() (includes ASN, currency, flag, continent, etc.)
  • Authentication via X-Api-Key header
  • Graceful error handling (returns defaults on failure)

Configuration

// config/ip-geolocation.php
'driver' => 'ip2geo',

'ip2geo' => [
    'key' => env('IPGEOLOCATION_IP2GEO_KEY'),
],

Files changed

  • New: src/Drivers/IP2GeoDriver.php — driver implementation
  • Modified: src/IPGeolocationManager.php — added createIp2geoDriver() factory method
  • Modified: config/ip-geolocation.php — added ip2geo config section

Test plan

  • php -l syntax check passes
  • get('134.201.250.155') returns normalized data (Los Angeles, CA, 34.0544, -118.244)
  • getRaw() returns full API response with ASN, currency, etc.
  • Bad API key gracefully returns defaults (all null)
  • Manager resolves ip2geo driver correctly

Add a new driver for the ip2geo.dev IP geolocation API. Supports
IPv4 and IPv6 with city, country, region, coordinates, timezone,
and postal code. Authentication via X-Api-Key header.

Configuration:
    'driver' => 'ip2geo',
    'ip2geo' => ['key' => env('IPGEOLOCATION_IP2GEO_KEY')]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant