2017 © Pedro Peláez
 

library geoip2-geolite2-composer

This tiny repository aims to provide an easy solution to require GeoIP2 / GeoLite2 databases inside your project using composer.

image

bobey/geoip2-geolite2-composer

This tiny repository aims to provide an easy solution to require GeoIP2 / GeoLite2 databases inside your project using composer.

  • Tuesday, February 13, 2018
  • by bobey
  • Repository
  • 1 Watchers
  • 12 Stars
  • 77,305 Installations
  • Shell
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 0 Open issues
  • 6 Versions
  • 7 % Grown

The README.md

GeoIP2 / GeoLite2 for Composer

Description

This tiny repository aims to provide an easy solution to require GeoIP2 / GeoLite2 databases inside your project using composer. This is particularly usefull if you use it in conjunction with the GeoIP2 PHP API., (*1)

Install via composer

Just run the following command in your project root:, (*2)

composer require bobey/geoip2-geolite2-composer

Use it with the GeoIP2 PHP API

composer require geoip2/geoip2:~2.0

City Example rewritten

The following example is the one provided in the GeoIP2 PHP API README rewritten to lookup the GeoLite2 database inside your vendors directory., (*3)

<?php
require_once 'vendor/autoload.php';
use GeoIp2\Database\Reader;

// This creates the Reader object, which should be reused across
// lookups.
$reader = new Reader('vendor/bobey/geoip2-geolite2-composer/GeoIP2/GeoLite2-City.mmdb');

// Replace "city" with the appropriate method for your database, e.g.,
// "country".
$record = $reader->city('128.101.101.101');

print($record->country->isoCode . "\n"); // 'US'
print($record->country->name . "\n"); // 'United States'
print($record->country->names['zh-CN'] . "\n"); // '美国'

print($record->mostSpecificSubdivision->name . "\n"); // 'Minnesota'
print($record->mostSpecificSubdivision->isoCode . "\n"); // 'MN'

print($record->city->name . "\n"); // 'Minneapolis'

print($record->postal->code . "\n"); // '55455'

print($record->location->latitude . "\n"); // 44.9733
print($record->location->longitude . "\n"); // -93.2323

Update

GeoLite2 databases are updated on the first Tuesday of each month. I will try to update and tag a new version of this repository as often as possible. In the meantime, if you want to update the databases yourself, just fork the repository, execute the update script by running the following command:, (*4)

./scripts/update.sh

Then, just make a pull request!, (*5)

License

The GeoLite2 databases are distributed under the Creative Commons Attribution-ShareAlike 3.0 Unported License. The attribution requirement may be met by including the following in all advertising and documentation mentioning features of or use of this database:, (*6)

This product includes GeoLite2 data created by MaxMind, available from http://www.maxmind.com., (*7)

The Versions

13/02 2018

dev-master

9999999-dev

This tiny repository aims to provide an easy solution to require GeoIP2 / GeoLite2 databases inside your project using composer.

  Sources   Download

by Olivier Balais

geoip composer databases geolite mmdb

22/06 2017

v1.5.0

1.5.0.0

This tiny repository aims to provide an easy solution to require GeoIP2 / GeoLite2 databases inside your project using composer.

  Sources   Download

by Olivier Balais

geoip composer databases geolite mmdb

29/09 2015

v1.4.0

1.4.0.0

This tiny repository aims to provide an easy solution to require GeoIP2 / GeoLite2 databases inside your project using composer.

  Sources   Download

by Olivier Balais

geoip composer databases geolite mmdb

02/06 2015

v1.3.0

1.3.0.0

This tiny repository aims to provide an easy solution to require GeoIP2 / GeoLite2 databases inside your project using composer.

  Sources   Download

by Olivier Balais

geoip composer databases geolite mmdb

25/02 2015

v1.1.0

1.1.0.0

This tiny repository aims to provide an easy solution to require GeoIP2 / GeoLite2 databases inside your project using composer.

  Sources   Download

by Olivier Balais

geoip composer databases geolite mmdb

04/02 2015

v1.0.0

1.0.0.0

This tiny repository aims to provide an easy solution to require GeoIP2 / GeoLite2 databases inside your project using composer.

  Sources   Download

by Olivier Balais

geoip composer databases geolite mmdb