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

ActiveLibrary

trrtly/ip2region
================

hyperf ip2region

v3.2.0(2y ago)34.4k↓20%2MITPHPPHP &gt;=7.2

Since Nov 27Pushed 2y ago1 watchersCompare

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

READMEChangelog (5)Dependencies (8)Versions (6)Used By (0)

hyperf ip2region
================

[](#hyperf-ip2region)

针对 hyperf 的 [ip2region](https://github.com/lionsoul2014/ip2region) 组件，采用速度最快的 [memorySearch](https://github.com/lionsoul2014/ip2region/blob/master/binding/php/ReadMe.md#%E7%BC%93%E5%AD%98%E6%95%B4%E4%B8%AA-xdb-%E6%95%B0%E6%8D%AE)方式查询，在框架初始化时就将db文件载入内存

参考

- [ip2region](https://github.com/lionsoul2014/ip2region?tab=readme-ov-file#2%E6%8A%80%E6%9C%AF%E8%B5%84%E6%BA%90%E5%88%86%E4%BA%AB)
- [数据结构和查询过程](https://mp.weixin.qq.com/s/ndjzu0BgaeBmDOCw5aqHUg)
- [兼容Ip2Region](https://github.com/zoujingli/ip2region/blob/master/Ip2Region.php)

安装
--

[](#安装)

```
composer require trrtly/ip2region
```

示例
--

[](#示例)

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

class Example
{
    /**
     * @Inject
     * @var Ip2region
     */
    protected $ip2region;

    public function query()
    {
        $address = $this->ip2region->memorySearch($ip);
        var_dump($address);
    }
}
```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 75% 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 ~191 days

Total

5

Last Release

867d ago

Major Versions

v0.0.2 → v3.0.02023-03-14

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/16716327?v=4)[trrtly](/maintainers/trrtly)[@trrtly](https://github.com/trrtly)

---

Top Contributors

[![trrtly](https://avatars.githubusercontent.com/u/16716327?v=4)](https://github.com/trrtly "trrtly (6 commits)")[![suyar](https://avatars.githubusercontent.com/u/15704489?v=4)](https://github.com/suyar "suyar (2 commits)")

---

Tags

phphyperfIp2Region

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[firstphp/ip2region

ip2region for hyperf

138.7k](/packages/firstphp-ip2region)

PHPackages © 2026

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