PHPackages                             statsig/ip3country - 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. statsig/ip3country

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

statsig/ip3country
==================

IP address to 2-letter country code lookup

v0.1.0(4y ago)0583.1k↓52%1ISCPHPPHP &gt;=7.0.0

Since Jan 20Pushed 4y ago1 watchersCompare

[ Source](https://github.com/statsig-io/ip3country-php)[ Packagist](https://packagist.org/packages/statsig/ip3country)[ Docs](https://github.com/statsig-io/ip3country-php)[ RSS](/packages/statsig-ip3country/feed)WikiDiscussions main Synced 3d ago

READMEChangelog (1)Dependencies (1)Versions (3)Used By (1)

ip3country
==========

[](#ip3country)

This is a zero-dependency, super small, IP address to 2-letter [country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) lookup library. There are already several libraries available, but none met our requirements for binary size and speed.

This project in its entirety is &lt;500KB, compared to most alternatives out there that are north of 40MB (but might provide more than just countries).

The database used in this project is compacted from [IP2Location](https://lite.ip2location.com/database/ip-country). Their DB1.LITE edition is provided under CCA, with the attribution below:

---

**NOTE**

This site or product includes IP2Location LITE data available from [](https://lite.ip2location.com).

---

Usage
-----

[](#usage)

```
$ composer require statsig/ip3country
```

```
// import
require_once __DIR__ . '/../vendor/autoload.php';
use ip3country\IP3Country;

// Initialize
$ip3c = new IP3Country();

// Lookup using ip4 str
echo $ip3c->lookup("1.1.1.1"); // 'US'
echo $ip3c->lookup("123.45.67.8"); // 'KR'

// Lookup using numeric ip
echo ip3country.lookupNumeric(2066563848)); // 'KR'
```

Tests
-----

[](#tests)

```
./vendor/bin/phpunit tests/TestCountries.php
```

Accuracy
--------

[](#accuracy)

`ip3country`'s accuracy is dependent on IP2Location LITE's accuracy. In our experience, for country lookups, it is accurate enough for most applications.

IP2Location publishes accuracy reports here:

There's also this third party report available:

Name
----

[](#name)

All variants of "ip2country" were already taken in npm, so we decided to step it up.

Motivation
----------

[](#motivation)

At [Statsig](https://www.statsig.com), we needed a library to evaluate location-based conditions on Feature Gates (Feature Flags). We use ip3country to power country-level rollouts or A/B tests for new features.

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity36

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

1626d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2884e4308b4a3bf6b9e2734878b813781bb2ae29802cc883ff0ec000488077c8?d=identicon)[experiment@amplitude.com](/maintainers/experiment@amplitude.com)

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

![](https://avatars.githubusercontent.com/u/95646168?v=4)[Daniel](/maintainers/daniel-statsig)[@daniel-statsig](https://github.com/daniel-statsig)

---

Top Contributors

[![tore-statsig](https://avatars.githubusercontent.com/u/74584483?v=4)](https://github.com/tore-statsig "tore-statsig (4 commits)")

---

Tags

locationcountryipaddresscountry code

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/statsig-ip3country/health.svg)

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

###  Alternatives

[torann/geoip

Support for multiple Geographical Location services.

2.2k15.3M98](/packages/torann-geoip)[kartik-v/yii2-ipinfo

An IP address information display widget for Yii 2.0 with country flag and geo position info.

2833.6k1](/packages/kartik-v-yii2-ipinfo)[hibit-dev/geodetect

Automatically detect user's geo data based on their IP address

2322.8k](/packages/hibit-dev-geodetect)[sun/country

Sun Country is the package that helps you to get the country name &amp; dialing code by the country ISO 3166-1 Alpha-2 code.

1016.8k](/packages/sun-country)[tastaturberuf/anystores

Location management and geographic search

121.7k](/packages/tastaturberuf-anystores)

PHPackages © 2026

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