PHP code example of dimanzver / sxgeo
1. Go to this page and download the library: Download dimanzver/sxgeo 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/ */
dimanzver / sxgeo example snippets
$app['sypex_geo'] = [];
$app['sypex_geo']['database'] = 'SxGeoCity.dat';
$app->register(new \Astartsky\SypexGeo\Silex\SypexGeoServiceProvider());
class AwesomeApplication extends \Silex\Application
{
...
use SypexGeoTrait;
...
}
$city = $app->getSypexGeoAdapter()->getCity(**IP**)
var_dump($city);
object(Astartsky\SypexGeo\Bean\City)[613]
protected 'id' => int 524901
protected 'latitude' => float 55.75222
protected 'longitude' => float 37.61556
protected 'nameRu' => string 'Москва' (length=12)
protected 'nameEn' => string 'Moscow' (length=6)
protected 'region' =>
object(Astartsky\SypexGeo\Bean\Region)[612]
protected 'id' => int 524894
protected 'iso' => string 'RU-MOW' (length=6)
protected 'nameRu' => string 'Москва' (length=12)
protected 'nameEn' => string 'Moskva' (length=6)
protected 'country' =>
object(Astartsky\SypexGeo\Bean\Country)[611]
protected 'id' => int 185
protected 'iso' => string 'RU' (length=2)
protected 'latitude' => int 60
protected 'longitude' => int 100
protected 'nameRu' => string 'Россия' (length=12)
protected 'nameEn' => string 'Russia' (length=6)