jairovsky/geoplugin

GeoPlugin.com library for PHP 5.3+

This package's canonical repository appears to be gone and the package has been frozen as a result.

dev-master 2014-07-06 14:10 UTC

This package is not auto-updated.

Last update: 2022-11-22 23:57:14 UTC


README

Build status

Is a tiny little PHP 5.3+ wrapper library for GeoPlugin webservice. This library is my first composer project, so bear with me in case of any silly error.

Installation

Add the following line to your composer.json file require section:

"jairovsky/geoplugin": "dev-master"

and run composer update.

Usage

Once installed, just use it like this:

use Jairovsky\GeoPlugin\Factory;

$ip = '173.194.118.3'; // example IP address

$factory = new Factory;

$geolocation = $factory->getGeolocation($ip);

print $geolocation->getProperty('countryName'); // prints 'United States'
print $geolocation->getProperty('city');
//et cetera
...

For the full list of properties, take a look at the geoplugin documentation.

Plans for the future

  • Add a validator for IP addresses
  • Add a caching mechanism
  • Add a domain name resolver so we can get geolocation data for domain names

Tests

Since this package has no dev. dependencies, to run the tests you just need to run composer install and then phpunit .