PHP Geolocation Library
PHP
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib/Yer
.gitignore
LICENSE
README.md
composer.json

README.md

What is Yer?

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