PHPackages                             shaojjjin/ip2region - 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. shaojjjin/ip2region

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

shaojjjin/ip2region
===================

Ip2Region for PHP

v1.0.5(7y ago)2354Apache-2.0PHPPHP &gt;=5.3

Since Mar 22Pushed 7y ago1 watchersCompare

[ Source](https://github.com/shaojjjin/ip2region)[ Packagist](https://packagist.org/packages/shaojjjin/ip2region)[ Docs](https://github.com/shaojjjin/ip2region)[ RSS](/packages/shaojjjin-ip2region/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)DependenciesVersions (7)Used By (0)

[![Latest Stable Version](https://camo.githubusercontent.com/26f597857d6aff2815ddb28ef8920d0d33aa282726fa9aab324bfb3bbe132b21/68747470733a2f2f706f7365722e707567782e6f72672f7a6f756a696e676c692f697032726567696f6e2f762f737461626c65)](https://packagist.org/packages/zoujingli/ip2region)[![Total Downloads](https://camo.githubusercontent.com/fea5425209aec0e2b48e106321adfd87d5e439382fe50beae8b657c0560dfa66/68747470733a2f2f706f7365722e707567782e6f72672f7a6f756a696e676c692f697032726567696f6e2f646f776e6c6f616473)](https://packagist.org/packages/zoujingli/ip2region)[![Latest Unstable Version](https://camo.githubusercontent.com/1409367e22a62c6a6bd5522682e281a5ac3f5a34c7ff00ebb1f1d977ad945f56/68747470733a2f2f706f7365722e707567782e6f72672f7a6f756a696e676c692f697032726567696f6e2f762f756e737461626c65)](https://packagist.org/packages/zoujingli/ip2region)[![License](https://camo.githubusercontent.com/ee87b0a81848a3a55eab7bbf50e91082e0771e55c7f22606be589d7ed1f0e03a/68747470733a2f2f706f7365722e707567782e6f72672f7a6f756a696e676c692f697032726567696f6e2f6c6963656e7365)](https://packagist.org/packages/zoujingli/ip2region)

本库基于 [lionsoul2014/ip2region](https://github.com/lionsoul2014/ip2region) 和 [zoujingli/ip2region](https://github.com/zoujingli/ip2region) ，整合使用`composer`来管理。

同时重新打包了`ip2region.db`文件，使用`GBT2260`国家行政区域划分代码作为city\_id的返回值。

\--

[ip2region](https://github.com/lionsoul2014/ip2region) - 最自由的ip地址查询库，ip到地区的映射库，提供Binary,B树和纯内存三种查询算法，妈妈再也不用担心我的ip地址定位。

### 1. 99.9%准确率，定时更新：

[](#1-999准确率定时更新)

数据聚合了一些知名ip到地名查询提供商的数据，这些是他们官方的的准确率，经测试着实比纯真啥的准确多了。
每次聚合一下数据需要1-2天，会不定时更新。

### 2. 标准化的数据格式：

[](#2-标准化的数据格式)

每条ip数据段都固定了格式：*城市Id|国家|区域|省份|城市|ISP*

只有中国的数据精确到了城市，其他国家只能定位到国家，后前的选项全部是0，已经包含了全部你能查到的大大小小的国家。

### 3. 体积：

[](#3-体积)

数据库文件`ip2region.db`重新打包后大小为3.3M

### Composer 安装

[](#composer-安装)

```
composer require shaojjjin/ip2region

```

### ip2region 使用

[](#ip2region-使用)

```
$ip2region = new Ip2Region();

$ip = '101.105.35.57';

$info = $ip2region->btreeSearch($ip);

var_export($info, true);

// array (
//     'city_id' => 440300,
//     'region' => '中国|华南|广东省|深圳市|鹏博士',
// )
```

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 85.7% 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 ~99 days

Recently: every ~124 days

Total

6

Last Release

2842d ago

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

v1.0.4PHP &gt;=5.3

### Community

Maintainers

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

---

Top Contributors

[![zoujingli](https://avatars.githubusercontent.com/u/4349951?v=4)](https://github.com/zoujingli "zoujingli (12 commits)")[![shaojjjin](https://avatars.githubusercontent.com/u/10897827?v=4)](https://github.com/shaojjjin "shaojjjin (2 commits)")

---

Tags

Ip2Region

### Embed Badge

![Health badge](/badges/shaojjjin-ip2region/health.svg)

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

PHPackages © 2026

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