2017 © Pedro Peláez
 

library geoip2-provider

Geocoder GeoIP2 adapter

image

geocoder-php/geoip2-provider

Geocoder GeoIP2 adapter

  • Saturday, March 3, 2018
  • by Nyholm
  • Repository
  • 2 Watchers
  • 1 Stars
  • 24,281 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 32 % Grown

The README.md

GeoIP2 Geocoder provider

Build Status Latest Stable Version Total Downloads Monthly Downloads Quality Score Software License, (*1)

This is the GeoIP2 provider from the PHP Geocoder. This is a READ ONLY repository. See the main repo for information and documentation., (*2)

Install

composer require geocoder-php/geoip2-provider

Usage

The provider requires either a database file, or paid access to the web service., (*3)

Using a database file

Both free geolite2 and the paid precision city and country databases are supported., (*4)

``` php //Use a Maxmind GeoIP2 Database: $reader = new \GeoIp2\Database\Reader('/path/to/geolite2.mmdb');, (*5)

$adapter = new \Geocoder\Provider\GeoIP2\GeoIP2Adapter($reader); $geocoder = new \Geocoder\Provider\GeoIP2\GeoIP2($adapter);, (*6)

$address = $geocoder->geocodeQuery(\Geocoder\Query\GeocodeQuery::create('74.200.247.59'))->first();, (*7)


### Using the Precision Web Service (API) The provider also support the Precision Web Services. Please note that these API are paid, and billed per request. ``` php // Use the Maxmind GeoIP2 API: $reader = new \GeoIp2\WebService\Client(<account_id>, '<licence_key>'); $adapter = new \Geocoder\Provider\GeoIP2\GeoIP2Adapter($reader); $geocoder = new \Geocoder\Provider\GeoIP2\GeoIP2($adapter); $address = $geocoder->geocodeQuery(\Geocoder\Query\GeocodeQuery::create('74.200.247.59'))->first();

Contribute

Contributions are very welcome! Send a pull request to the main repository or report any issues you find on the issue tracker., (*8)

The Versions