wakumaku / ip2c
Small and simple library to resolve the country where an Ip comes from.
v1.0.1
2016-04-19 12:18 UTC
Requires
- ext-curl: *
Requires (Dev)
- phpunit/phpunit: 4.5.1
This package is not auto-updated.
Last update: 2025-01-14 20:51:45 UTC
README
Ip2c is a small php library to retrieve the country where an Ip comes from.
This library uses http://ip2c.org as a service.
Installation
Prerequisites
Ip2c requires PHP 5.3.3 or greater.
If you want to run the tests you'll need a greater one (>=5.5)
Setup through composer
First, add Ip2c to the list of dependencies inside your composer.json
:
{ "require": { "wakumaku/ip2c": "dev-master" } }
Composer update:
$> composer update
How to use it
include vendor/autoload.php'; $ip2c = \Ip2c\Ip2cFactory::build(); $result = $ip2c->self(); echo "Status: " . $result->status() . "\n"; echo "Iso2: " . $result->iso2() . "\n"; echo "Iso3: " . $result->iso3() . "\n"; echo "Name: " . $result->name() . "\n";
Output:
Status: 1
Iso2: ES
Iso3: ESP
Name: Spain