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

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

simplephp/ip2region
===================

ip2region for hyperf

1.0.1(5y ago)019MITPHPPHP &gt;=7.2

Since Apr 13Pushed 5y ago1 watchersCompare

[ Source](https://github.com/simplephp/ip2region)[ Packagist](https://packagist.org/packages/simplephp/ip2region)[ RSS](/packages/simplephp-ip2region/feed)WikiDiscussions master Synced 1w ago

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

ip2region for hyperf
====================

[](#ip2region-for-hyperf)

本项目 Fork From [狂奔的蚂蚁](https://github.com/firstphp/ip2region), 只是格式化了返回结果。 本库基于 [ip2region](https://github.com/lionsoul2014/ip2region) ，适配Hyperf，可通过注解来使用。

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

99.9%准确率，定时更新
-------------

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

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

标准化的数据格式
--------

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

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

只有中国的数据精确到了城市，其他国家只能定位到国家，后前的选项全部是0，已经包含了全部你能查到的大大小小的国家。 （请忽略前面的城市Id，个人项目需求）

体积小
---

[](#体积小)

数据库文件是ip2region.db

安装组件
----

[](#安装组件)

> composer require simplephp/ip2region

使用范例
----

[](#使用范例)

```
use Hyperf\Di\Annotation\Inject;

......

/**
 * @Inject()
 * @var \Firstphp\Ip2region\Ip2Region
 */
protected $ip2region;

......

$res = $this->ip2region->binarySearch($ip = "223.104.148.63");

var_dump($res);

// Array
// (
//     [city_id] => 1015
//     [country] => 中国
//     [regionCode] => 0
//     [province] => 江苏省
//     [city] => 南京市
//     [operators] => 移动
// )
```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 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

1861d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5bc85954b85968faaebd19c2a95d42399e528ef9c8b792174ac2e79c0a21fb0d?d=identicon)[simplephp](/maintainers/simplephp)

---

Top Contributors

[![simplephp](https://avatars.githubusercontent.com/u/5026959?v=4)](https://github.com/simplephp "simplephp (3 commits)")

---

Tags

phpswoolehyperfIp2Region

### Embed Badge

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

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

PHPackages © 2026

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