eabay/yer

This package is abandoned and no longer maintained. No replacement package was suggested.

PHP Geolocation Library

dev-master 2012-08-07 13:57 UTC

This package is not auto-updated.

Last update: 2020-01-24 14:58:55 UTC


README

Yer is a PHP geolocation library.

Usage

Install it via composer eabay/yer

Locator Providers

Geobytes

<?php
require_once __DIR__.'/vendor/autoload.php';

$geolocation = new Yer\Geolocation;
$geolocation->setLocator(new Yer\Locator\GeobytesLocator());

var_dump($geolocation->lookup('193.140.215.133'));

You can turn ssl on/off:

<?php
...
$geolocation->setLocator(new Yer\Locator\GeobytesLocator(true));

If you have a paid subscription,

<?php
...
$geolocation->setLocator(new Yer\Locator\GeobytesLocator(true /* or false */, 'your email', 'your password'));

MaxMind

<?php
...
$geolocation->setLocator(new Yer\Locator\MaxMindWebServiceLocator('your license key'));

You can use your custom locator providers by implementing Yer\Locator\LocatorInterface.

IP Address Validation

You can validate IP address before query to the locator provider

<?php
...
$geolocation->setIpValidator(new Yer\Validator\IpValidator())

If you want to use your own validator implement Yer\Validator\ValidatorInterface