2017 © Pedro Peláez
 

yii2-extension yii2-geoip2

Yii2 GeoIP2 extension. Returns country, city, latitude, longitude, time zone, iso code, continent, subdivisions by IP (uses MaxMind's GeoIP2 databases)

image

overals/yii2-geoip2

Yii2 GeoIP2 extension. Returns country, city, latitude, longitude, time zone, iso code, continent, subdivisions by IP (uses MaxMind's GeoIP2 databases)

  • Thursday, April 12, 2018
  • by overals
  • Repository
  • 1 Watchers
  • 0 Stars
  • 680 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 4 Versions
  • 5 % Grown

The README.md

Yii2 GeoIP2 extension

Provides information about geographical location of user by IP address., (*1)

Currently available: * Country * City * Latitude, Longitude * Time Zone * ISO Code * Continent * Subdivisions, (*2)

Installation

$ php composer.phar require overals/yii2-geoip2 "~1.0.1"

OR

Add to your composer.json, (*3)

{
    "require": {
        "overals/yii2-geoip2": "~1.0.1"
    }
}

and run, (*4)

$ composer update

Usage

Update your config file - config/web.php, (*5)

<?php

$config = [
    ...
    'components' => [
        'geoip2' => [
            'class' => 'overals\GeoIP2\GeoIP2',
            'mmdb' => '@app/components/GeoIP2/GeoLite2-City.mmdb',
            'lng' => 'en', // available languages = 'de', 'en', 'es', 'ja', 'ru', 'zh-CN'
        ],
    ]
    ...
];

somewhere in code:, (*6)

$ip = Yii::$app->component->geoip2->getInfoByIP(); // current user ip
$ip = Yii::$app->component->geoip2->getInfoByIP("8.8.8.8");

$ip->continent; // "North America"
$ip->country; // "United States"
$ip->isoCode; // "US"
$ip->subdivisions; // "California"
$ip->city; // "Mountain View"
$ip->location->longitude; // -122.0838
$ip->location->latitude; // 37.386

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

Where you can download Maxmind Free DBs?

From http://dev.maxmind.com/geoip/geoip2/geolite2/, (*8)

OR

    cd /usr/local/share/GeoIP (change to your folder)
    wget -N -q http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz
    gunzip -c GeoLite2-City.mmdb.gz > GeoLite2-City.mmdb

The Versions

12/04 2018

dev-master

9999999-dev

Yii2 GeoIP2 extension. Returns country, city, latitude, longitude, time zone, iso code, continent, subdivisions by IP (uses MaxMind's GeoIP2 databases)

  Sources   Download

MIT

The Requires

 

The Development Requires

by Evgeny Gorchak

yii2 maxmind geoip2 geodata

12/04 2018

1.0.2

1.0.2.0

Yii2 GeoIP2 extension. Returns country, city, latitude, longitude, time zone, iso code, continent, subdivisions by IP (uses MaxMind's GeoIP2 databases)

  Sources   Download

MIT

The Requires

 

The Development Requires

by Evgeny Gorchak

yii2 maxmind geoip2 geodata

03/12 2016

1.0.1

1.0.1.0

Yii2 GeoIP2 extension. Returns country, city, latitude, longitude, time zone, iso code, continent, subdivisions by IP (uses MaxMind's GeoIP2 databases)

  Sources   Download

MIT

The Requires

 

The Development Requires

by Evgeny Gorchak

yii2 maxmind geoip2 geodata

03/12 2016

1.0.0

1.0.0.0

Yii2 GeoIP2 extension. Returns country, city, latitude, longitude, time zone, iso code, continent, subdivisions by IP (uses MaxMind's GeoIP2 databases)

  Sources   Download

MIT

The Requires

 

The Development Requires

by Evgeny Gorchak

yii2 maxmind geoip2 geodata