manzadey/sypexgeo

Supports GeoIP services

Fund package maintenance!
Open Collective

v0.1 2021-10-27 13:31 UTC

This package is auto-updated.

Last update: 2024-04-27 19:02:57 UTC


README

This package is intended for obtaining information about the IP address using the service database https://sypexgeo.net

Installation

composer require "manzadey/sypexgeo"

How used

Create an instance of the class and specify the path to the file and operation mode flags as arguments (optional):

use Manzadey\SypexGeo\SxGeo;

$sxGeo = new SxGeo('sxGeo.dat');

Defining the country:

$country = $sxGeo->getCountry($ip); // returns a two-digit ISO country code
$sxGeo->getCountryId($ip);          // returns the country number

Defining the city:

$sxGeo->getCity($ip);                 // returns brief information, without the name of the region, country and time zone
$sxGeo->getCityFull($ip);             // returns full information about the city, region and country
$city = $sxGeo->get($ip);             // executes getCountry or getCity depending on the type of database
$cityName = $sxGeo->getCityName($ip); // returns the name of the city