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

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

chenyongze/ip2region
====================

Ip2Region

v2.0.1(5y ago)1221Apache 2.0PHPPHP &gt;=5.3.3

Since Mar 22Pushed 5y ago1 watchersCompare

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

READMEChangelog (1)DependenciesVersions (4)Used By (1)

[![Latest Stable Version](https://camo.githubusercontent.com/918b6b200f6a68090ea48cc9dfbb7331a7353b7450d8cf1f847244013fb12afe/68747470733a2f2f706f7365722e707567782e6f72672f6368656e796f6e677a652f697032726567696f6e2f762f737461626c65)](https://packagist.org/packages/chenyongze/ip2region)[![Total Downloads](https://camo.githubusercontent.com/fa178104ef6ad74100845cca3bf572edd098e01b2afe8772354a3ccc7f7996f2/68747470733a2f2f706f7365722e707567782e6f72672f6368656e796f6e677a652f697032726567696f6e2f646f776e6c6f616473)](https://packagist.org/packages/chenyongze/ip2region)[![Latest Unstable Version](https://camo.githubusercontent.com/c482b3dcae3ad46668005f48e7a446cbafa74f282717a145f2bf127718c52f98/68747470733a2f2f706f7365722e707567782e6f72672f6368656e796f6e677a652f697032726567696f6e2f762f756e737461626c65)](https://packagist.org/packages/chenyongze/ip2region)[![License](https://camo.githubusercontent.com/48aca5511b686d548a4c614262dfd2ac5021f0264224f61071ea5dc3c659db96/68747470733a2f2f706f7365722e707567782e6f72672f6368656e796f6e677a652f697032726567696f6e2f6c6963656e7365)](https://packagist.org/packages/chenyongze/ip2region)

本库基于 [ip2region](https://github.com/lionsoul2014/ip2region) ，简单整合方便使用`composer`来管理。
-----------------------------------------------------------------------------------

[](#本库基于-ip2region-简单整合方便使用composer来管理)

[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，已经包含了全部你能查到的大大小小的国家。 （请忽略前面的城市Id，个人项目需求）

### 3. 体积小：

[](#3-体积小)

数据库文件ip2region.db只有1.5M

### Composer 安装

[](#composer-安装)

```
composer require chenyongze/ip2region

```

### ip2region 使用

[](#ip2region-使用)

```
$ip2region = new Ip2Region();

$ip = '101.105.35.57';

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

var_export($info, true);

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

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 58.3% 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 ~604 days

Total

3

Last Release

2182d ago

Major Versions

v1.0.1 → v2.0.12020-07-13

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4531363?v=4)[Chen,Yongze](/maintainers/chenyongze)[@chenyongze](https://github.com/chenyongze)

---

Top Contributors

[![zoujingli](https://avatars.githubusercontent.com/u/4349951?v=4)](https://github.com/zoujingli "zoujingli (7 commits)")[![chenyongze](https://avatars.githubusercontent.com/u/4531363?v=4)](https://github.com/chenyongze "chenyongze (5 commits)")

---

Tags

Ip2Region

### Embed Badge

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

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

###  Alternatives

[zoujingli/ip2region

ip2region v3.0 for PHP - 企业级 IP 地理位置查询库，支持 IPv4 和 IPv6，多种缓存策略，零依赖，开箱即用

1.4k475.0k67](/packages/zoujingli-ip2region)[firstphp/ip2region

ip2region for hyperf

138.7k](/packages/firstphp-ip2region)[swisnl/filament-activitylog

Integrates spatie/laravel-activitylog with Filament

164.5k](/packages/swisnl-filament-activitylog)

PHPackages © 2026

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