PHPackages                             aknife/ip - 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. aknife/ip

ActiveLibrary

aknife/ip
=========

获取ip信息，支持ipv4和 ipv6

v1.0.6(8mo ago)263.3k↓33.3%41MITPHPPHP &gt;=5.6

Since Jun 9Pushed 8mo ago1 watchersCompare

[ Source](https://github.com/aknife2019/ip)[ Packagist](https://packagist.org/packages/aknife/ip)[ Docs](https://aknife.cn)[ RSS](/packages/aknife-ip/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (7)Dependencies (1)Versions (8)Used By (1)

概述
--

[](#概述)

IP地理位置获取。支持获取IPv4、IPv6地址信息。包括：国家、省份、城市。

国内数据使用纯真IPV4库，结合 ipip,ip138 API 补齐国内空白城市数据，并打包为mmdb格式

测试地址：

安装
--

[](#安装)

```
composer require aknife/ip
```

快速入门
----

[](#快速入门)

示例代码

```
// 获取IP信息
use Aknife\Ip\IpInfo;

// IPv4
IpInfo::find('159.75.190.197');
/*
[
    'continent' => [
            'code' => 'AS',
            'name' => '亚洲',
    ],
    'country' => [
            'code' => 'CN',
            'name' => '中国',
    ],
    'region' => '广东省',
    'city' => '广州市',
]
*/
// IPv4 en
IpInfo::find('159.75.190.197','en');
/*
[
    [continent] => [
            [code] => 'AS',
            [name] => 'Asia',
    ],
    [country] => [
            [code] => 'CN',
            [name] => 'China',
    ],
    [region] => 'Guangdong',
    [city] => 'Guangzhou'
]
*/

// IPv6
IpInfo::find('2402:4e00:1013:e500:0:940e:29d7:3443','full');
/*
[

    'continent' => [
            'code' => 'AS',
            'en' => 'Asia',
            'zh-CN' => '亚洲'
    ],
    'country' => [
            'code' => 'CN',
            'en' => 'China',
            'zh-CN' => '中国'
    ],
    'region' => [
            'en' => 'Guangdong',
            'zh-CN' => '广东省'
    ],
    'city' => [
            'en' => 'Guangzhou',
            'zh-CN' => '广州市'
    ]
]
*/
```

IP库来源
-----

[](#ip库来源)

- 国内IPv4地址来自(qqwry.dat - 2025-08-27)[纯真网络](https://cz88.net/),数据源来自 [metowolf/qqwary.dat](https://github.com/metowolf/qqwry.dat)
- 国内IPv6地址来自(ipv6wry.db - 2021-07-21) [ZX-Inc/zxipdb-python](https://github.com/ZX-Inc/zxipdb-python)
- 国外IP城市信息来自(GeoLite2-City.mmdb - 2025-08-29) [maxmind.com](https://www.maxmind.com/)

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance59

Moderate activity, may be stable

Popularity31

Limited adoption so far

Community12

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

Every ~196 days

Recently: every ~288 days

Total

7

Last Release

262d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/176fe4f4076da44eee3ed401f8d6e80e12f6f6c9eef1d7bd8452d64512cec672?d=identicon)[aknife2019](/maintainers/aknife2019)

---

Top Contributors

[![aknife2019](https://avatars.githubusercontent.com/u/50777910?v=4)](https://github.com/aknife2019 "aknife2019 (13 commits)")

---

Tags

ip-databasemaxmindphp-ipqqwryqqwry-mmdbIPipaddressiplocationQQWry.datQQWry转mmdb

### Embed Badge

![Health badge](/badges/aknife-ip/health.svg)

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

###  Alternatives

[geoip2/geoip2

MaxMind GeoIP2 PHP API

2.5k85.4M294](/packages/geoip2-geoip2)[stevebauman/location

Retrieve a user's location by their IP Address

1.3k7.6M65](/packages/stevebauman-location)[zoujingli/ip2region

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

1.4k437.1k56](/packages/zoujingli-ip2region)[mlocati/ip-lib

Handle IPv4, IPv6 addresses and ranges

3126.4M44](/packages/mlocati-ip-lib)[s1lentium/iptools

PHP Library for manipulating network addresses (IPv4 and IPv6)

2446.2M24](/packages/s1lentium-iptools)[vectorface/whip

A PHP class for retrieving accurate IP address information for the client.

3781.1M14](/packages/vectorface-whip)

PHPackages © 2026

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