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

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

hisune/ip2region
================

Ip2Region for PHP

v1.0.7(5y ago)1353Apache-2.0PHPPHP &gt;=5.3

Since Mar 22Pushed 5y ago1 watchersCompare

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

READMEChangelog (2)DependenciesVersions (9)Used By (0)

[![Latest Stable Version](https://camo.githubusercontent.com/ef2cfeb06702a930a599e719adec6efa05c196b2a87a58bdd9679603f14cc55a/68747470733a2f2f706f7365722e707567782e6f72672f686973756e652f697032726567696f6e2f762f737461626c65)](https://packagist.org/packages/hisune/ip2region)[![Total Downloads](https://camo.githubusercontent.com/989bbefb35b1a3455956765354c745227502eff6d6b45bb354163808405f527d/68747470733a2f2f706f7365722e707567782e6f72672f686973756e652f697032726567696f6e2f646f776e6c6f616473)](https://packagist.org/packages/hisune/ip2region)[![Latest Unstable Version](https://camo.githubusercontent.com/e885c38c40e1b41068093b4b657a9ab594ce498cc4cffa0b06c85aaf4396f9b3/68747470733a2f2f706f7365722e707567782e6f72672f686973756e652f697032726567696f6e2f762f756e737461626c65)](https://packagist.org/packages/hisune/ip2region)[![License](https://camo.githubusercontent.com/102aea7d3d4d8fe3f53d147c7b42ee1f660f9bcb0a8c3f5c0e565103e9d982ed/68747470733a2f2f706f7365722e707567782e6f72672f686973756e652f697032726567696f6e2f6c6963656e7365)](https://packagist.org/packages/hisune/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 hisune/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

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 76.5% 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 ~204 days

Recently: every ~248 days

Total

8

Last Release

1907d 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/7a4ef0906f517b5dcc4658de9d066e7661a6267adcaff49c0cff77278d254e94?d=identicon)[hisune](/maintainers/hisune)

---

Top Contributors

[![zoujingli](https://avatars.githubusercontent.com/u/4349951?v=4)](https://github.com/zoujingli "zoujingli (13 commits)")[![hisune](https://avatars.githubusercontent.com/u/7941669?v=4)](https://github.com/hisune "hisune (4 commits)")

---

Tags

Ip2Region

### Embed Badge

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

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

###  Alternatives

[ralphjsmit/laravel-seo

A package to handle the SEO in any Laravel application, big or small.

841433.3k21](/packages/ralphjsmit-laravel-seo)

PHPackages © 2026

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