PHP code example of johnsnook / yii2-visitors

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/ */

    

johnsnook / yii2-visitors example snippets


    'bootstrap' => [
        'log',
        'visitor',
    ],

    'modules' => [
        ...
        'visitor' => [
            'class' => 'johnsnook\visitor\Module',
        ],
        ...
    ],

    'visitor' => '/visitor/visitor/index',
    'visitor/index' => '/visitor/visitor/index',
    'visitor/blowoff' => '/visitor/visitor/blowoff',
    'visitor/<id>' => 'visitor/visitor/view',
    'visitor/update/<id>' => 'visitor/visitor/update',

    '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";
    }
bash
php composer.phar 
http://yoursit.biz/index.php?r=visitor/visitor/index