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)0514.2k—8.2%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 1mo 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 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity36

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity35

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

1580d ago

### Community

Maintainers

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

![](https://www.gravatar.com/avatar/0e5a5eb311267b336499cdd1600a79ba6b301de7b5a8800ecfce2eb1e8cba38a?d=identicon)[daniel-statsig](/maintainers/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

[components/flag-icon-css

A curated collection of all country flags in SVG — plus the CSS for easier integration.

12.0k1.6M23](/packages/components-flag-icon-css)[torann/geoip

Support for multiple Geographical Location services.

2.2k14.2M76](/packages/torann-geoip)[rinvex/countries

Rinvex Countries is a simple and lightweight package for retrieving country details with flexibility. A whole bunch of data including name, demonym, capital, iso codes, dialling codes, geo data, currencies, flags, emoji, and other attributes for all 250 countries worldwide at your fingertips.

1.7k7.4M48](/packages/rinvex-countries)[stevebauman/location

Retrieve a user's location by their IP Address

1.3k7.6M65](/packages/stevebauman-location)[spatie/geocoder

Geocoding addresses to coordinates

8404.8M15](/packages/spatie-geocoder)[kigkonsult/icalcreator

iCalcreator is the PHP implementation of rfc2445/rfc5545 and rfc updates, management of calendar information

2462.6M16](/packages/kigkonsult-icalcreator)

PHPackages © 2026

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