PHPackages                             timur-flush/sypexgeo - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. timur-flush/sypexgeo

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

timur-flush/sypexgeo
====================

v2.0.1(6y ago)0102[2 issues](https://github.com/TimurFlush/geo-detector/issues)MITPHPPHP ^7.4CI failing

Since Mar 26Pushed 6y ago1 watchersCompare

[ Source](https://github.com/TimurFlush/geo-detector)[ Packagist](https://packagist.org/packages/timur-flush/sypexgeo)[ RSS](/packages/timur-flush-sypexgeo/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (12)Versions (8)Used By (0)

[![Build Status](https://camo.githubusercontent.com/40ecb7691fdcfd783689bfa32eb90ac32e86fe42d79049193444d3993458da9e/68747470733a2f2f7472617669732d63692e6f72672f54696d7572466c7573682f67656f2d6465746563746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/TimurFlush/geo-detector)[![Coverage Status](https://camo.githubusercontent.com/237d8c05ecead6693277adc9fb53a7b17baad64d92d970eaf2bf8d0f34702d13/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f54696d7572466c7573682f67656f2d6465746563746f722f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/TimurFlush/geo-detector?branch=master)

GeoDetector
===========

[](#geodetector)

This library allows to receive geodata of any IP address.

Installation
------------

[](#installation)

```
composer require timur-flush/geo-detector
```

Available adapters
------------------

[](#available-adapters)

### SypexGeo (Local base)

[](#sypexgeo-local-base)

Usage:

```
use TimurFlush\GeoDetector\Adapter\Sypex;

# With custom database
$adapter = new Sypex('/path/to/custom/database');

# With custom mode
$adapter = new Sypex(null, Sypex::SXGEO_FILE | Sypex::SXGEO_MEMORY | Sypex::SXGEO_BATCH);

# With custom database & custom mode
$adapter = new Sypex('/path/to/custom/database', Sypex::SXGEO_FILE | Sypex::SXGEO_MEMORY | Sypex::SXGEO_BATCH);

# Default (also see auto-downloading)
$adapter = new Sypex();
```

You can use auto-downloading database. For example: composer.json

```
"extra": {
  "TF_Sypex_Link": "http://link.to.sypex.database.archive.zip",
  "TF_Sypex_PathToDatabase": "path/to/db/in/your/project.dat"
},
"scripts": {
  "post-install-cmd": [
    "TimurFlush\\GeoDetector\\Adapter\\Sypex\\Composer::updateDatabase"
  ],
  "post-update-cmd": [
    "TimurFlush\\GeoDetector\\Adapter\\Sypex\\Composer::updateDatabase"
  ]
}
```

Please note that:

1. The `extra.TF_Sypex_Link` by default is `https://sypexgeo.net/files/SxGeoCountry.zip`
2. The `extra.TF_Sypex_PathToDatabase` by default is `./Adapter/Sypex/sypex-database.dat`
3. A default database path is `./Adapter/Sypex/sypex-database.dat`
4. Depending on the content of the Sypex database, you may not receive some geo information.

### SypexGeo (API)

[](#sypexgeo-api)

Usage:

```
use TimurFlush\GeoDetector\Adapter\SypexAPI;

# With custom SypexGeo server
$adapter = new SypexAPI('custom.server.com');

# With license key
$adapter = new SypexAPI(null, 'your-license-key');

# With custom server & license ky
$adapter = new SypexAPI('custom.server.com', 'your-license-key');

# Default
$adapter = new SypexAPI();
```

Please note that:

1. A server by default is `api.sypexgeo.net`
2. Without a license you can get only 10k request per month.

#### MaxMind

[](#maxmind)

Usage:

```
use TimurFlush\GeoDetector\Adapter\MaxMind;

$adapter = new MaxMind('path/to/database.mmdb');
```

#### MaxMind (API)

[](#maxmind-api)

Usage:

```
use TimurFlush\GeoDetector\Adapter\MaxMindAPI;

$accountId = 0;
$licenseKey = 'your-license-key';

$adapter = new MaxMindAPI($accountId, $licenseKey);
```

Providing a geo data information
--------------------------------

[](#providing-a-geo-data-information)

ProvideAll()

```
use TimurFlush\GeoDetector\Entity\GeoData;
use TimurFlush\GeoDetector\Entity\Country;
use TimurFlush\GeoDetector\Entity\Region;
use TimurFlush\GeoDetector\Entity\City;

/**
 * Provides all geo data information
 * @var GeoData $geoData
 */
$geoData = $adapter->provideAll('8.8.8.8');

$geoData->getClientAddress(); // 8.8.8.8

/**
 * @var Country $country
 */
$country = $geoData->getCountry();
$country->getName(); // returns: United States of America
$country->getIso(); //  returns: US
$country->getLatitude(); // returns a latitude if it's exist
$country->getLongitude(); // returns a longitude if it's exist
$country->getTimeZone(); // returns a timezone if it's exist

/**
 * @var Region $region
 */
$region  = $geoData->getRegion();
$region->getName(); // returns a region name if it's exist
$region->getIso(); //  returns a region code if it's exist
$region->getLatitude(); // returns a latitude if it's exist
$region->getLongitude(); // returns a longitude if it's exist
$region->getTimeZone(); // returns a timezone if it's exist

/**
 * @var City $city
 */
$city    = $geoData->getCity();
$city->getName(); // returns a region name if it's exist
$city->getIso(); //  returns a region code if it's exist
$city->getLatitude(); // returns a latitude if it's exist
$city->getLongitude(); // returns a longitude if it's exist
$city->getTimeZone(); // returns a timezone if it's exist

$geoData->getTimeZone(); // get timezone in order city, region, country
$geoData->getLatitude(); // get latitude in order from city, region, country
$geoData->getLongitude(); // get longitude in order from city, region, country
$geoData->getTorStatis(); // determine if the address is an output node in the Tor network

$geoData->toJson(); // convert object to json
GeoData::createFromJson('{...}'); // create from json
```

---

ProvideCountry()

```
/*
 * The behavior is identical to the provideCountry() method.
 * The difference is that it will return an array of country names.
 */
$adapter->provideCountriesBatch(['1.1.1.1', '8.8.8.8']); // ['AU', 'US']
```

---

ProvideAllBatch(array $array)

```
/*
 * The behavior is identical to the provideAll() method.
 * The difference is that it will return an array of GeoData objects.
 */
$adapter->provideAllBatch(['1.1.1.1', '8.8.8.8']); // GeoData[]
```

Author
------

[](#author)

Name: Timur F.

Email:

License
-------

[](#license)

BSD 3-Clause

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~118 days

Recently: every ~176 days

Total

7

Last Release

2260d ago

Major Versions

v1.0.2 → v2.0.0-RC12020-02-29

PHP version history (2 changes)v1.0.0PHP &gt;=5.3.0

v2.0.0-RC1PHP ^7.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/29764676?v=4)[timurflush](/maintainers/TimurFlush)[@TimurFlush](https://github.com/TimurFlush)

---

Top Contributors

[![iginikolaev](https://avatars.githubusercontent.com/u/4067742?v=4)](https://github.com/iginikolaev "iginikolaev (2 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/timur-flush-sypexgeo/health.svg)

```
[![Health](https://phpackages.com/badges/timur-flush-sypexgeo/health.svg)](https://phpackages.com/packages/timur-flush-sypexgeo)
```

###  Alternatives

[pocketmine/pocketmine-mp

A server software for Minecraft: Bedrock Edition written in PHP

3.5k74.6k86](/packages/pocketmine-pocketmine-mp)[symplify/monorepo-builder

Not only Composer tools to build a Monorepo.

5205.3M81](/packages/symplify-monorepo-builder)[friendsoftypo3/content-blocks

TYPO3 CMS Content Blocks - Content Types API | Define reusable components via YAML

96374.6k23](/packages/friendsoftypo3-content-blocks)[solspace/craft-freeform

The most flexible and user-friendly form building plugin!

52664.9k12](/packages/solspace-craft-freeform)[shyim/danger-php

Port of danger to PHP

8544.9k](/packages/shyim-danger-php)[eliashaeussler/typo3-solver

Extension for TYPO3 CMS to extend TYPO3's exception handling with AI generated solutions

292.1k](/packages/eliashaeussler-typo3-solver)

PHPackages © 2026

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