Skip to content

sablesoft/yii2-geoip

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Yii2 GeoIP

Installation

The preferred way to install the geoip is through composer.

Either run

composer require sablesoft/yii2-geoip

or add

"sablesoft/yii2-geoip": "*",

to the require section of your composer.json.

Then add geoip in your app config:

    'components' => [
        'geoip'   => [
            'class'      => 'sablesoft\geoip\GeoIP',
            'dbPath'     => '/path/to/your/geoip/database'
        ]
    ]

How to Use

Use get method to get IP data:

$ip = "52.141.159.163";
/** @var \sablesoft\geoip\IpData $ipData */
$ipData = \Yii::$app->geoip->get($ip);
$country = $ipData->countryName;
$city   = $ipData->cityName;
$code = $ipData->countryCode;

$default = false;
$path = "some.path.in.ip.data.array";
$someData = $ipData->get($path, $default);

About

Yii2 GeoIP Component

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages