1. Go to this page and download the library: Download johnsnook/yii2-visitors 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/ */
'modules' => [
...
'visitor' => [
'class' => 'johnsnook\visitor\Module',
'ipInfoKey' => 'Not a real key, obviously',
'proxyCheckKey' => 'Not a real key, obviously',
'mapquestKey' => 'Not a real key, obviously',
'blowOff' => 'site/nope',
'ignorables' => [
'acontroller' => ['ignore-me', 'ignore-that'],
'whitelist' => ['127.0.0.1', '24.99.155.86']
]
],
...
],
$visitor = \Yii::$app->getModule('visitor')->visitor;
// give a special hello to people in Atlanta or your ex wife
if ($visitor->info->city === 'Atlanta' || $visitor->info->ip_address === '99.203.4.238') {
echo "Your city sucks balls";
}