rmrevin/yii2-geoip

This package is abandoned and no longer maintained. The author suggests using the geoip2/geoip2 package instead.

GeoIP helper for Yii2

Maintainers

👁 rmrevin

Package info

github.com/rmrevin/yii2-geoip

Type:yii2-extension

pkg:composer/rmrevin/yii2-geoip

Statistics

Installs: 3 442

Dependents: 0

Suggesters: 0

Stars: 28

Open Issues: 1

1.1.0 2016-05-27 15:42 UTC

Requires

Requires (Dev)

None

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT 839d36248b72971522686f870eb77ad6bde6c205

geogeoiphelperyiiIP

This package is not auto-updated.

Last update: 2019-07-28 08:11:04 UTC


README

DEPRECATED

This package is no longer supported because MaxMind no longer supports the correct version of the database. Use official package geoip2/geoip2.

Installation

Install php5-geoip extension.

Add in composer.json:

{
 "require": {
 "rmrevin/yii2-geoip": "~1.1"
 }
}

Usage

In view

<?
// ...

/** @var \rmrevin\yii\geoip\HostInfo $Info */
$Info = \Yii::createObject([
 'class' => '\rmrevin\yii\geoip\HostInfo',
 'host' => 'phptime.ru', // some host or ip
]);

// check available
$Info->isAvailable();

// obtaining all data
$Info->getData();

// obtaining the individual parameters
$Info->getContinentCode(); // NA
$Info->getCountryCode(); // US
$Info->getCountryCode3(); // USA
$Info->getCountryName(); // United States
$Info->getRegion(); // MI
$Info->getRegionName(); // Michigan
$Info->getCity(); // Southfield
$Info->getPostalCode(); // 48075
$Info->getLatitude(); // 42.465000152588
$Info->getLongitude(); // -83.230697631836
$Info->getDmaCode(); // 505
$Info->getAreaCode(); // 248
$Info->getTimeZone(); // America/New_York

FAQ

Q: I get error Required database not available at /usr/share/GeoIP/GeoIPCity.dat.. What to do?

A: Download this file (this file is no more available) http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz and ungzip it into /usr/share/GeoIP/GeoIPCity.dat