depx/phalcon-sypexgeo

There is no license information available for the latest version (1.0.1) of this package.

Sypex Geo for Phalcon

1.0.1 2019-06-01 18:34 UTC

This package is auto-updated.

Last update: 2024-04-29 04:13:10 UTC


README

Configuration

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

Download files

$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

Download one file

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

Get city base

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

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

Get country base

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

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