1. Go to this page and download the library: Download kostikpenzin/yii2-geoip 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/ */
kostikpenzin / yii2-geoip example snippets
$geo = new \kostikpenzin\geoip\Geoip();
// get by remote IP
$geo->get(); // also returned geo data as array
echo $geo->ip,'<br>';
echo $geo->ipAsLong,'<br>';
var_dump($geo->country); echo '<br>';
var_dump($geo->region); echo '<br>';
var_dump($geo->city); echo '<br>';
// get by custom IP
print_r($geo->get('88.200.214.22'));