PHPackages                             hostbrook/sypex-geo - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. hostbrook/sypex-geo

ActivePackage

hostbrook/sypex-geo
===================

Get location info by IP address

1.8(1y ago)1415.6k↓38.4%7Apache-2.0PHPPHP &gt;=5.3.0

Since Jul 4Pushed 1y ago2 watchersCompare

[ Source](https://github.com/hostbrook/sypex-geo)[ Packagist](https://packagist.org/packages/hostbrook/sypex-geo)[ RSS](/packages/hostbrook-sypex-geo/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (8)DependenciesVersions (9)Used By (0)

Sypex Geo - Get location info by IP address
===========================================

[](#sypex-geo---get-location-info-by-ip-address)

This extension is based on [Sypex Geo free databases](https://sypexgeo.net/) and lets you get the next info by IP address:

- Country code by ISO 3166-2
- Region code by ISO 3166-2
- City name
- Region name
- Country name
- City Latitude/Longitude data

The language requirements: PHP version &gt;=5.3.0

The databases release date: **March 16, 2025**

PHP frameworks integration
--------------------------

[](#php-frameworks-integration)

You have to use Composer to add Sypex Geo to your project based on PHP frameworks like Laravel, Yii, etc.

### Installation

[](#installation)

To get the latest version via Composer:

```
composer require hostbrook/sypex-geo

```

Usage
-----

[](#usage)

There are two different databases that come with the extension SxGeo.dat (country database, around 814kb) and SxGeoCity.dat (city database, around 39Mb). The city database contains the same country info from the country database, but heavier. So, do not use the city database if you need to get just a country code.

### Usage with country database

[](#usage-with-country-database)

If you need to get just a 2-symbol country code by ISO 3166-2:

```
// Add namespace at the beginning of the file:
use HostBrook\SypexGeo\SypexGeo;

...

// Create an object with the country database in the argument.
// Note: By default, the country database (SxGeo.dat) is used, so it can be skipped:
$SxGeo = new SypexGeo();

// get your IP address, for example:
$userIP = $_SERVER['REMOTE_ADDR'];

// Option 1 to get the ISO country code:
$userCountry = $SxGeo->getCountry($userIP); // returns string, the country code
// Option 2  is a short equialent for country database only:
$userCountry = $SxGeo->get($userIP);        // returns string, the country code

```

### Usage with city database

[](#usage-with-city-database)

```
// Add namespace at the beginning of the file:
use HostBrook\SypexGeo\SypexGeo;

...

// Create an object with the city database in the argument:
$SxGeo = new SypexGeo('SxGeoCity.dat');

// Get your IP address, like an example:
$userIP = $_SERVER['REMOTE_ADDR'];

// Option 1 to get the city info:
var_dump( $SxGeo->getCity($userIP) );     // Array, the short info about a city
// Option 2 is a short equialent for the city database only:
var_dump( $SxGeo->get($userIP) );         // Array, the short info about a city

// City full info with timezone and region:
var_dump( $SxGeo->getCityFull($userIP) ); // Full info about a city

```

Example Data:

```
[
    'city' => [
        'id' => 524901,
        'lat' => 55.75222,
        'lon' => 37.61556,
        'name_ru' => 'Москва',
        'name_en' => 'Moscow',
        'okato' => '45',
    ],
    'region' => [
        'id' => 524894,
        'lat' => 55.76,
        'lon' => 37.61,
        'name_ru' => 'Москва',
        'name_en' => 'Moskva',
        'iso' => 'RU-MOW',
        'timezone' => 'Europe/Moscow',
        'okato' => '45',
    ],
    'country' => [
        'id' => 185,
        'iso' => 'RU',
        'continent' => 'EU',
        'lat' => 60,
        'lon' => 100,
        'name_ru' => 'Россия',
        'name_en' => 'Russia',
        'timezone' => 'Europe/Moscow',
    ],
];

```

### Addition parameters

[](#addition-parameters)

If you need to work with multiple requests to a database, you can add two parameters during object creating to use caching and packet mode:

```
$SxGeo = new SypexGeo('SxGeoCity.dat', SXGEO_BATCH | SXGEO_MEMORY);

```

it can increase a response speed.

Upgrading
---------

[](#upgrading)

Whenever there is a new release, then from the command line in your **project root**:

```
composer update

```

Deleting package
----------------

[](#deleting-package)

Running the following command will remove the package from vendor folder:

```
composer remove hostbrook/sypex-geo

```

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance45

Moderate activity, may be stable

Popularity36

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 93.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~193 days

Recently: every ~214 days

Total

8

Last Release

427d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0c707f620b47059c1ae4ccbb4f9a81a3e6bfba09f0ede96c6e38ecdc5f7a3bc4?d=identicon)[hostbrook](/maintainers/hostbrook)

---

Top Contributors

[![hostbrook](https://avatars.githubusercontent.com/u/42077512?v=4)](https://github.com/hostbrook "hostbrook (14 commits)")[![microwin7](https://avatars.githubusercontent.com/u/12544425?v=4)](https://github.com/microwin7 "microwin7 (1 commits)")

---

Tags

3166-2geoipgeolocationisosypexsypex-geo

### Embed Badge

![Health badge](/badges/hostbrook-sypex-geo/health.svg)

```
[![Health](https://phpackages.com/badges/hostbrook-sypex-geo/health.svg)](https://phpackages.com/packages/hostbrook-sypex-geo)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
