PHP code example of chocofamilyme / phalcon-geo-data

1. Go to this page and download the library: Download chocofamilyme/phalcon-geo-data 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/ */

    

chocofamilyme / phalcon-geo-data example snippets


...
$geoDataService = new GeoDataService($this->config, $this->cache);
/** @var \Chocofamily\GeoData\DTO\GeoDTO $geoData */
$geoDTO        = $geoDataService->getGeoDTO($ipAddress);

/** Можно достать данные по-отдельности */
$country = $geoDTO->country;
$city    = $geoDTO->city;
$region  = $geoDTO->region;
$lat     = $geoDTO->lat;
$lon     = $geoDTO->lon;

/**
 * Либо можно достать в виде массива. Пример:
 * [
 *      'country' => 'Kazakhstan',
 *      'city' => 'Almaty',
 *      'region' => 'ALA',
 *      'lat' => '12.345',
 *      'lon' => '12.345',
 * ]
 */
$geoData = $geoDTO->toArray();
...