PHP code example of sem-soft / yii2-ipgeobase
1. Go to this page and download the library: Download sem-soft/yii2-ipgeobase library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sem-soft / yii2-ipgeobase example snippets
...
'components' => [
...
'geo' => [
'class' => \sem\ipgeobase\IpGeoBase::className(),
'serviceTimeout' => 2
],
...
],
...
if ($g = Yii::$app->geo->geo) {
echo $g->city;
}
if ($g = Yii::$app->geo->getGeo('86.XXX.YYY.ZZZ')) {
echo $g->city;
}
if ($g = Yii::$app->geo->getCityInfo('Москва')) {
echo $g->city;
}