PHPackages                             atchondjo/geoip2country - 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. atchondjo/geoip2country

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

atchondjo/geoip2country
=======================

A lightweight but powerful IP address lookup database solution to determine visitors country

v2.0.6(3y ago)344.1k—5.6%10[1 issues](https://github.com/iriven/GeoIP2Country/issues)proprietaryPHPPHP &gt;=7.4

Since Dec 6Pushed 2y ago4 watchersCompare

[ Source](https://github.com/iriven/GeoIP2Country)[ Packagist](https://packagist.org/packages/atchondjo/geoip2country)[ Docs](https://github.com/iriven/GeoIP2Country)[ Fund](https://www.paypal.com/donate/?hosted_button_id=ZCGRGGSB4XS4W)[ RSS](/packages/atchondjo-geoip2country/feed)WikiDiscussions master Synced 1mo ago

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

PHP GeoIP2Country PRO (v2.0.6)
==============================

[](#php-geoip2country-pro-v206)

[![Donate](https://camo.githubusercontent.com/604e3db9c8751116b3f765aad0353ec7ded655bbe8aaacbc38d8c4a6b784b3ed/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f6e6174652d50617950616c2d677265656e2e737667)](https://www.paypal.com/donate/?hosted_button_id=ZCGRGGSB4XS4W)[![Build Status](https://camo.githubusercontent.com/d04bee0d95ff995c59f4cf1ea7a0866a94f87cb9f6e300bb01f7485ae4143447/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f69726976656e2f47656f495032436f756e7472792f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/iriven/GeoIP2Country/build-status/master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/a0a2d1e0633f474157867f96c31af47ca6d9015e5976d7ed0e595f8c9f682da4/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f69726976656e2f47656f495032436f756e7472792f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/iriven/GeoIP2Country/?branch=master)[![Code Intelligence Status](https://camo.githubusercontent.com/70dd3e6a45bb7b4c92a41bdd6a71409ffd2f126a0d66ab209bc29323cd22a31f/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f69726976656e2f47656f495032436f756e7472792f6261646765732f636f64652d696e74656c6c6967656e63652e7376673f623d6d6173746572)](https://scrutinizer-ci.com/code-intelligence)[![GitHub license](https://camo.githubusercontent.com/aed477ac82de60abd644cfa7c9d381eebe9a00d5d32168644f7e6d2a23957d1b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4147504c2d626c75652e737667)](https://github.com/iriven/GeoIP2Country/blob/master/LICENSE)

An IP address is only the beginning of endless possibilities, adventures and developments...

What's GeoIP2Country PRO?
-------------------------

[](#whats-geoip2country-pro)

A PHP IP Address Geolocation library to help you identify visitors geographical location. This component is Build with an eye to keeping it as lightweight and lookups as fast as possible. And there are no external requests being made during runtime. So, if you need to get your website visitor's country and you don't want to use any API then this is the best solution for you. The project include methods to quickly update your GEOIP DATABASE with the least possible human intervention (for donors only).

What's new in this release?
---------------------------

[](#whats-new-in-this-release)

- Complete refactoring and optimization of processing algorithms
- A new database engine (combining security and efficiency)
- A new component dedicated to updating the database?
- A repository based on statistical data from [ICANN](https://www.icann.org) (Internet Corporation for Assigned Names and Numbers)

#### NOTE:

[](#note)

**In order to encourage people to support this project, database update components are not included in this repository as they are for donors only. Thus any donor will receive a full copy of this software, including the component that will help him to make his GEOIP database stay up to date. However, other users can still use the software as published here. Only the database update functionality will not be available**

**Donate here:** [![Donate](https://camo.githubusercontent.com/604e3db9c8751116b3f765aad0353ec7ded655bbe8aaacbc38d8c4a6b784b3ed/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f6e6174652d50617950616c2d677265656e2e737667)](https://www.paypal.com/donate/?hosted_button_id=ZCGRGGSB4XS4W)

Requirements
------------

[](#requirements)

- pdo\_sqlite (runtime deps)
- php\_curl (for update only)

Installation And Initialisation :
---------------------------------

[](#installation-and-initialisation-)

These instructions will get you a copy of the project up and running on your local machine. there are two options:

- import(copy) GeoIP2Country files into a specific folder of your project
- Using Composer installer(Recommended) by typing the following command:

```
composer require atchondjo/geoip2country
```

Usage: (using Composer autoloader)
----------------------------------

[](#usage-using-composer-autoloader)

```
require __DIR__ . '/vendor/autoload.php';

try
{
    $IP2Country = new iriven\GeoIP2Country();

} catch (\Throwable $th) {
    trigger_error($th->getMessage(), E_USER_ERROR);
}
```

#### Getting Country code from given IP address:

[](#getting-country-code-from-given-ip-address)

```
    $ipAddress_1='2a00:1450:4007:816::2004';
    $ipAddress_2='37.140.250.97';
    $ipAddress_3='2001:41d0:301::21';
    $ipAddress_4='216.58.201.228';
    $ipAddress_5='188.165.53.185';
    $ipAddress_6='10.10.201.12';

    echo '';
    echo $IP2Country->resolve($ipAddress_1).PHP_EOL;
    echo $IP2Country->resolve($ipAddress_2).PHP_EOL;
    echo $IP2Country->resolve($ipAddress_3).PHP_EOL;
    echo $IP2Country->resolve($ipAddress_4).PHP_EOL;
    echo $IP2Country->resolve($ipAddress_5).PHP_EOL;
    echo $IP2Country->resolve($ipAddress_6).PHP_EOL;
```

#### Getting current visitor Country code (auto detect his IP address):

[](#getting-current-visitor-country-code-auto-detect-his-ip-address)

```
    echo '';
    echo $IP2Country->resolve().PHP_EOL;  /** resolve() method called without any argument */
```

#### Retrieving Country name:

[](#retrieving-country-name)

Because one of my publications already deals with the recovery of a country's name from its ISO code. I chose in this project to limit myself to the only search of the country's ALPHA2 ISO code from a given ip address. So, to retrieve the country name (and much more), you must instantiate the "WorldCountriesDatas" class available from [HERE](https://github.com/iriven/WorldCountriesDatas), and pass the result of the previous command as follows:

```
$CountryName ='n/a';
$CountryCode = $IP2Country->resolve($ipAddress);
if(!$IP2Country->isReservedAddress($ipAddress))
{
  require_once 'WorldCountriesDatas.php';
  $DataProvider = new \Iriven\WorldCountriesDatas();
  $CountryName = $DataProvider->getCountryName($CountryCode);
}
```

#### Updating GeoIP datas: (for Donors only)

[](#updating-geoip-datas-for-donors-only)

```
require __DIR__ . '/vendor/autoload.php';

try
{
    $IP2CountryBackend = new iriven\GeoIP2CountryServer();
    $IP2CountryBackend->updateDatabase();

} catch (\Throwable $th) {
    trigger_error($th->getMessage(), E_USER_ERROR);
}

/*
* NOTE: In order to encourage people to support this project, database update components are not included in this
* repository as they are for donors only. Thus any donor will receive a full copy of this software,
* including the component that will help him to make his GEOIP database stay up to date.
*/
```

Compatibility:
--------------

[](#compatibility)

- IPV4
- IPV6

Authors
-------

[](#authors)

- **Alfred TCHONDJO** - *Project Initiator* - [Iriven France](https://www.facebook.com/Tchalf)

License
-------

[](#license)

This project is licensed under the GNU General Public License V3 - see the [LICENSE](LICENSE) file for details

Donation
--------

[](#donation)

If this project help you reduce time to develop, you can give me a cup of coffee :)

[![Donate](https://camo.githubusercontent.com/604e3db9c8751116b3f765aad0353ec7ded655bbe8aaacbc38d8c4a6b784b3ed/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f6e6174652d50617950616c2d677265656e2e737667)](https://www.paypal.com/donate/?hosted_button_id=ZCGRGGSB4XS4W)

Acknowledgments
---------------

[](#acknowledgments)

- This project uses GeoIp data by ICANN, available from [Here](https://www.icann.org)

Disclaimer
----------

[](#disclaimer)

If you use this library in your project please add a backlink to this page by this code.

```
This Project Uses Alfred's TCHONDJO GeoIP2Country PRO.
```

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity35

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 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 ~65 days

Total

3

Last Release

1129d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ef0ee340c543927f1726ae276835f31f614b285efbe35c0178dbdcb5ae9d001e?d=identicon)[iriven](/maintainers/iriven)

---

Top Contributors

[![iriven](https://avatars.githubusercontent.com/u/6275596?v=4)](https://github.com/iriven "iriven (151 commits)")

---

Tags

countrygeogeoipgeoip-datageolocationipip2countryipv4ipv6irivenphpgeoipgeolocationip2locationip geolocationipaddressIP2Countryip2location lite

### Embed Badge

![Health badge](/badges/atchondjo-geoip2country/health.svg)

```
[![Health](https://phpackages.com/badges/atchondjo-geoip2country/health.svg)](https://phpackages.com/packages/atchondjo-geoip2country)
```

###  Alternatives

[torann/geoip

Support for multiple Geographical Location services.

2.2k14.2M76](/packages/torann-geoip)[ip2location/ip2location-php

\[Official Release\] IP2Location PHP API to get location info from IPv4 and IPv6 address.

2133.9M33](/packages/ip2location-ip2location-php)[interaction-design-foundation/laravel-geoip

Support for multiple Geographical Location services.

17221.0k3](/packages/interaction-design-foundation-laravel-geoip)[ip2location/ip2location-cakephp

Lookup for visitor's IP information, such as country, region, city, coordinates, zip code, time zone, ISP, domain name, connection type, area code, weather, MCC, MNC, mobile brand name, elevation and usage type.

224.6k](/packages/ip2location-ip2location-cakephp)

PHPackages © 2026

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