Skip to content

Add ip2geo IP geolocation provider#1269

Open
bfzli wants to merge 1 commit intogeocoder-php:masterfrom
bfzli:add-ip2geo-provider
Open

Add ip2geo IP geolocation provider#1269
bfzli wants to merge 1 commit intogeocoder-php:masterfrom
bfzli:add-ip2geo-provider

Conversation

@bfzli
Copy link
Copy Markdown

@bfzli bfzli commented Apr 20, 2026

Summary

  • Adds a new provider for the ip2geo IP geolocation API
  • Supports geocoding IPv4 and IPv6 addresses
  • Custom Ip2GeoAddress model with 20+ extra fields (ASN, currency, flag, continent, registered country, etc.)
  • Full unit test suite with mocked HTTP responses
  • Integration test scaffold (requires IP2GEO_API_KEY env var)
  • CI workflow for PHP 8.0–8.5

Provider details

  • API endpoint: GET https://api.ip2geo.dev/convert?ip={ip}
  • Authentication: X-Api-Key header (API key required, free tier available at ip2geo.dev)
  • Operations: Geocode (IP only) — no street address or reverse geocoding support

Files added

src/Provider/Ip2Geo/
├── .github/workflows/provider.yml
├── .gitignore
├── CHANGELOG.md
├── Ip2Geo.php              # Main provider class
├── Ip2GeoAddress.php        # Custom address model
├── LICENSE
├── README.md
├── Tests/
│   ├── .cached_responses/.gitkeep
│   ├── IntegrationTest.php
│   └── Ip2GeoTest.php
├── composer.json
└── phpunit.xml.dist

Test plan

  • php -l passes on all PHP files
  • composer install && vendor/bin/phpunit — 10 unit tests pass, 11 integration tests skip (no API key)
  • Live API test with real key returns correct data (city, country, coordinates, ASN, currency, etc.)
  • CI workflow validates against PHP 8.0–8.5

Add a new provider for the ip2geo.dev IP geolocation API.
Supports geocoding IP addresses (IPv4 and IPv6) with rich response
data including city, country, continent, ASN, currency, flag,
timezone, and registered country information.

- Provider class with PSR-18 HTTP client support
- Custom Ip2GeoAddress model with 20+ extra fields
- Unit tests with mocked HTTP responses
- Integration test scaffold
- CI workflow for PHP 8.0-8.5

API docs: https://ip2geo.dev/docs
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