2017 © Pedro Peláez
 

yii2-extension yii2-sypexgeo

Yii2 extension for Sypex Geo API (http://sypexgeo.net)

image

omnilight/yii2-sypexgeo

Yii2 extension for Sypex Geo API (http://sypexgeo.net)

  • Tuesday, December 2, 2014
  • by omnilight
  • Repository
  • 3 Watchers
  • 16 Stars
  • 8,970 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 2 Versions
  • 16 % Grown

The README.md

Yii2 extension for Sypex Geo API (http://sypexgeo.net)

This extension adds support for Sypex Geo to the Yii2 framework, (*1)

Note: This is not the fork of the JiSoft/yii2-sypexgeo!, (*2)

Installation

The preferred way to install this extension is through composer., (*3)

Either run, (*4)

php composer.phar require --prefer-dist omnilight/yii2-sypexgeo "*"

or add, (*5)

"omnilight/yii2-sypexgeo": "*"

to the require section of your composer.json., (*6)

What it is all about?

Sypex Geo - product for location by IP address. Obtaining the IP address, Sypex Geo outputs information about the location of the visitor - country, region, city, geographical coordinates and other in Russian and in English. Sypex Geo use local compact binary database file and works very quickly. For more information visit: http://sypexgeo.net/, (*7)

This is extension for Yii2 framework that makes it easy to deal with Sypex Geo., (*8)

Usage

Unfortunately original version of Sypex Geo does not support Composer installation, so we have to include it into this extension., (*9)

First of all, you have to download desired database from the http://sypexgeo.net/ website and place it somewhere on your server., (*10)

There are two classes in this extension., (*11)

Sypexgeo - this is the component that can be used to retrive Geo information based on IP address. This component incapsulates calls to the SxGeo methods., (*12)

You can use it as an application component:, (*13)

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

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

Also you can create instance by yourself:, (*14)


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

GeoBehavior - behavior that can be attached to the yii\web\Request or it's children and this class adds methods to simplify getting Geo information for current request., (*15)

Example:, (*16)

// config.php
[
    'components' => [
        'request' => [
            'as sypexGeo' => [
                'class' => 'omnilight\sypexgeo\GeoBehavior',
                // It is not required to define property sypexGeo if you have sypexGeo component defined
                // in your application
                'sypexGeo' => [
                    'database' => '@app/data/SxGeoCity.dat',
                ]
            ]
        ]
    ],
]

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

The Versions

02/12 2014

dev-master

9999999-dev

Yii2 extension for Sypex Geo API (http://sypexgeo.net)

  Sources   Download

The Requires

 

by Pavel Agalecky

yii2 geo sypexgeo

02/12 2014

1.0.0

1.0.0.0

Yii2 extension for Sypex Geo API (http://sypexgeo.net)

  Sources   Download

The Requires

 

by Pavel Agalecky

yii2 geo sypexgeo