PHP code example of omnilight / yii2-sypexgeo

1. Go to this page and download the library: Download omnilight/yii2-sypexgeo 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/ */

    

omnilight / yii2-sypexgeo example snippets


// config.php
[
    'components' => [
        'sypexGeo' => [
            'class' => 'omnilight\sypexgeo\SypexGeo',
            'database' => '@app/data/SxGeoCity.dat',
        ]
    ]
]

// somewhere in your code
$city = Yii::$app->sypexGeo->getCity($ip);


$sypexGeo = new omnilight\sypexgeo\Sypexgeo([
    'database' => '@app/data/SxGeoCity.dat',
]);
$city = $sypexGeo->getCity($ip);

// config.php
[
    'components' => [
        'request' => [
            'as sypexGeo' => [
                'class' => 'omnilight\sypexgeo\GeoBehavior',
                // It is not ]

// In your code
$city = Yii::$app->request->getCity();


php composer.phar