Yii Geo position getter extension
, (*1)
This extension will help you to find user country and country code.
It use two online and one offline system for find information about user. You no need worry
what system will use because all of this will do one component GeoFinder, (*2)
Installation
The preferred way to install this extension is through composer., (*3)
Either run, (*4)
php composer.phar require --prefer-dist yiicod/yii2-geo "*"
or add, (*5)
"yiicod/yii2-geo": "*"
to the require section of your composer.json., (*6)
Config for frontend
'container' => [
'singletons' => [
\yiicod\geo\storages\StorageInterface::class => [
'class' => \yiicod\geo\storages\CacheStorage::class,
],
],
],
'components' => [
'geoFinder' => [
'class' => yiicod\geo\components\GeoFinder::class,
'gettersList' => [
[
'class' => \yiicod\geo\adapters\geoIp2\GeoIp2CityAdapter::class,
'databaseConfig' => [
'class' => \yiicod\geo\adapters\geoIp2\GeoIp2Database::class,
'databaseAlias' => '@frontend/runtime',
],
],
[
'class' => \yiicod\geo\adapters\ipstack\IpstackAdapter::class,
'apiKey' => 'API-key'
],
[
'class' => \yiicod\geo\adapters\geoPlugin\GeoPluginAdapter::class,
],
],
],
],
Usage
```php
\yiicod\geo\GeoGetter::getCountryName($ip)
\yiicod\geo\GeoGetter::getCountryCode($ip)
\yiicod\geo\GeoGetter::getRegionName($ip),
\yiicod\geo\GeoGetter::getRegionCode($ip),
\yiicod\geo\GeoGetter::getCity($ip),
\yiicod\geo\GeoGetter::getLatitude($ip),
\yiicod\geo\GeoGetter::getLongitude($ip),
````, (*7)