PHP code example of depx / phalcon-sypexgeo

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

    

depx / phalcon-sypexgeo example snippets


return new \Phalcon\Config([
    //...
    'geo' => [
        'debug' => true,
        'path' => './geo-files',
        'types' => 1 | 2 // SXGEO_MEMORY | SXGEO_BATCH
    ],
    //...
]);

$geoClass = new \Geo\Geo();
$geoClass->downloadFiles(); // all
$geoClass->downloadFiles('city'); // city
$geoClass->downloadFiles(['city']); // city
$geoClass->downloadFiles('https://sypexgeo.net/files/SxGeoCity_utf8.zip'); // city
$geoClass->downloadFiles(['https://sypexgeo.net/files/SxGeoCity_utf8.zip', 'country']); // city and country

$geoClass = new \Geo\Geo();
$geoClass->downloadFile('https://sypexgeo.net/files/SxGeoCity_utf8.zip');

$geoClass = new \Geo\Geo();
$cityData = $geoClass->getCity();

$ip = $this->request->getClientAddress();
var_dump($cityData->getCityFull($ip));

$geoClass = new \Geo\Geo();
$countryData = $geoClass->getCountry();

$ip = $this->request->getClientAddress();
var_dump($countryData->getCountry($ip));