ip2geo-dev / sdk
Official PHP SDK for Ip2Geo - IP to Geolocation API
v0.0.1
2026-04-19 13:11 UTC
Requires
- php: ^8.0
- ext-curl: *
- ext-json: *
Requires (Dev)
- phpunit/phpunit: ^9.5|^10.0
This package is auto-updated.
Last update: 2026-04-19 13:18:20 UTC
README
Your go-to IP-to-Geo cloud service — fast, accurate, and built for developers. Start free with 1,000 monthly stored conversions.
Website • Dashboard • Documentation • Services Status
Intro to the PHP SDK
This package provides a lightweight, zero-dependency way to integrate Ip2Geo into your PHP applications.
Requirements
- PHP 8.0 or higher
- ext-curl
- ext-json
Installing
composer require ip2geo-dev/sdk
Initializing
use Ip2Geo\Ip2Geo; Ip2Geo::init('your-api-key');
You may also pass options:
Ip2Geo::init('your-api-key', [ 'version_update_message' => true, 'cache' => true, 'cache_max_size' => 1000, 'cache_ttl' => 300, ]);
Using
use Ip2Geo\Ip2Geo; $convertedIp = Ip2Geo::convertIp('8.8.8.8'); $convertedIps = Ip2Geo::convertIps([ '8.8.8.8', '1.1.1.1', '9.9.9.9', '64.6.64.6', ]); // [ // 'success' => true, // 'code' => 200, // 'message' => 'Success', // 'data' => [ ... ], // '_req' => [ // 'reqId' => 'string', // 'resTime' => 123, // ], // ]
Retrieving conversions
$conversion = Ip2Geo::getConversion('conversion-id'); $conversions = Ip2Geo::getConversions(['id-a', 'id-b']); $list = Ip2Geo::listConversions(0, 50);
Selecting fields
$conversion = Ip2Geo::getConversion('conversion-id', [ Ip2Geo::SELECT['IP'], Ip2Geo::SELECT['COUNTRY_NAME'], ]);
Validating an IP
$result = Ip2Geo::ipValidation('8.8.8.8'); // ['ip4' => true, 'ip6' => false]
Features
- Zero runtime dependencies (uses PHP built-ins only)
- Static facade — no instantiation required
- Built-in LRU cache with configurable size and TTL
- IPv4 and IPv6 validation
- Mirrors the official Python SDK behavior