sypex / geo
Sypex deo actualized
Installs: 1 632
Dependents: 1
Suggesters: 0
Security: 0
Stars: 2
Watchers: 3
Forks: 1
Open Issues: 0
Requires
- php: >=7.1
Requires (Dev)
- phpunit/phpunit: ^7.0 || ^8.0 || ^9.0 || ^10.0
README
Actualized library from https://sypexgeo.net/ru/.
- composer
- PSR-2
- PSR-4
throw
instead ofdie
- tests
Installation
composer require sypex/geo
Download Database file
wget https://sypexgeo.net/files/SxGeoCountry.zip unzip SxGeoCountry.zip rm SxGeoCountry.zip wget https://sypexgeo.net/files/SxGeoCity_utf8.zip unzip SxGeoCity_utf8.zip rm SxGeoCity_utf8.zip
Usage
$filepath = 'SxGeo.dat'; $geo = new Geo($filepath); // by default SxGeo.dat $geo = new SxGeo($filepath, Mode::BATCH | Mode::MEMORY); // the fastest way // Get country (SxGeo Country) // // 2-letter ISO code of country $country = $geo->getCountry($ip); // number of country $geo->getCountryId($ip); // get city (SxGeo City, SxGeo City Max) // // short information, without region name, country and timezone $geo->getCity($ip); // full city information $geo->getCityFull($ip); // calls getCountry or getCity depending on the type of base $city = $geo->get($ip); // free resource unset($geo);