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

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

tgkw-adc/ip2region
==================

hyperf ip2region

1.0.1(5mo ago)05MITPHPPHP &gt;=8.2

Since Nov 25Pushed 5mo agoCompare

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

READMEChangelogDependencies (8)Versions (2)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 tgkw-adc/ip2region
```

示例
--

[](#示例)

```
use TgkwAdc\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

33

—

LowBetter than 75% of packages

Maintenance71

Regular maintenance activity

Popularity4

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

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

166d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/47275a38ed23211949d825ec42b270e039f2b2ffd4803d1e2eb51c14fb8c8bff?d=identicon)[yangzai929](/maintainers/yangzai929)

---

Tags

phphyperfIp2Region

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

PHPackages © 2026

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