PHPackages                             hulang/think-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. [Database &amp; ORM](/categories/database)
4. /
5. hulang/think-ip

ActiveLibrary[Database &amp; ORM](/categories/database)

hulang/think-ip
===============

IP数据库 IPV4 IPV6(解析为国家、省、市、县、运营商)

1.0.19(1mo ago)3122MITPHPPHP &gt;=7.2.5

Since Aug 1Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/hulang/think-ip)[ Packagist](https://packagist.org/packages/hulang/think-ip)[ RSS](/packages/hulang-think-ip/feed)WikiDiscussions master Synced yesterday

READMEChangelog (3)DependenciesVersions (4)Used By (0)

### IP数据库 IPV4 IPV6(解析为国家、省、市、县、运营商)

[](#ip数据库-ipv4-ipv6解析为国家省市县运营商)

 您是第 [![](https://camo.githubusercontent.com/3af56c680c3b90e138a2d783c0874e2d9ddf12c1b85372c57aa497fba83b2c8d/68747470733a2f2f70726f66696c652d636f756e7465722e676c697463682e6d652f6769746875623a68756c616e673a7468696e6b2d69702f636f756e742e737667)](https://camo.githubusercontent.com/3af56c680c3b90e138a2d783c0874e2d9ddf12c1b85372c57aa497fba83b2c8d/68747470733a2f2f70726f66696c652d636f756e7465722e676c697463682e6d652f6769746875623a68756c616e673a7468696e6b2d69702f636f756e742e737667)位访问者

##### 环境

[](#环境)

- php &gt;= 7.2.5
- 修改自()
- 纯真IP库社区版更新(2024-07-24)

#### 安装

[](#安装)

```
composer require hulang/think-ip

```

```
//根据实际情况，基本上用框架(如 thinkphp,Laravel)的话不需要手动引入
//require 'vendor/autoload.php';

use think\IpLocation;

// 配置使用
echo json_encode(IpLocation::getLocation($ip), JSON_UNESCAPED_UNICODE) . PHP_EOL;

//支持自定义文件路径
$qqwry_filepath = '/abspath/qqwry.dat';
$ipv6wry_path = '/abspath/ipv6wry.db';
echo json_encode(IpLocation::getLocation($ip, $qqwry_filepath), JSON_UNESCAPED_UNICODE) . PHP_EOL;
```

#### 响应

[](#响应)

获取成功

```
{
    "code": 0,
    "error": "",
    "ip": "163.177.65.160",
    "country": "中国",
    "province": "广东",
    "city": "深圳市",
    "county": "",
    "area": "中国广东深圳市 联通",
    "isp": "联通"
}
```

异常

```
{
    "code": 1,
    "error": "ip invalid"
}
```

#### 本地测试\[IP\]

[](#本地测试ip)

```
{
    "code": 0,
    "error": "",
    "ip": "172.217.25.14",
    "country": "美国",
    "province": "",
    "city": "",
    "county": "",
    "area": "美国 Google全球边缘网络",
    "isp": ""
}
{
    "code": 0,
    "error": "",
    "ip": "140.205.172.5",
    "country": "中国",
    "province": "上海",
    "city": "",
    "county": "",
    "area": "中国上海 阿里云",
    "isp": ""
}
{
    "code": 0,
    "error": "",
    "ip": "123.125.115.110",
    "country": "中国",
    "province": "北京",
    "city": "",
    "county": "",
    "area": "中国北京 联通\/北京百度网讯科技有限公司联通节点(BGP)",
    "isp": "联通"
}
{
    "code": 0,
    "error": "",
    "ip": "221.196.0.0",
    "country": "中国",
    "province": "天津",
    "city": "河北区",
    "county": "",
    "area": "中国天津河北区 联通",
    "isp": "联通"
}
{
    "code": 0,
    "error": "",
    "ip": "60.195.153.98",
    "country": "中国",
    "province": "北京",
    "city": "",
    "county": "",
    "area": "中国北京 鹏博士\/BGP",
    "isp": ""
}
{
    "code": 0,
    "error": "",
    "ip": "fe80:0000:0001:0000:0440:44ff:1233:5678",
    "country": "局域网",
    "province": "",
    "city": "",
    "county": "",
    "area": "局域网 本地链路单播地址",
    "isp": ""
}
{
    "code": 0,
    "error": "",
    "ip": "2409:8900:103f:14f:d7e:cd36:11af:be83",
    "country": "中国",
    "province": "北京",
    "city": "",
    "county": "",
    "area": "中国北京 中国移动CMNET网络",
    "isp": "移动"
}
{
    "code": 0,
    "error": "",
    "ip": "58.196.128.0",
    "country": "中国",
    "province": "上海",
    "city": "",
    "county": "",
    "area": "中国上海 教育网\/上海交通大学",
    "isp": ""
}
{
    "code": 0,
    "error": "",
    "ip": "2409:8a00:6c1d:81c0:51b4:d603:57d1:b5ec",
    "country": "中国",
    "province": "北京",
    "city": "",
    "county": "",
    "area": "中国北京 中国移动公众宽带",
    "isp": "移动"
}
{
    "code": 0,
    "error": "",
    "ip": "210.74.2.227",
    "country": "中国",
    "province": "北京",
    "city": "",
    "county": "",
    "area": "中国北京 鹏博士BGP",
    "isp": ""
}

```

#### 感谢

[](#感谢)

1.纯真IP库(纯真宣布社区版只支持到`2024年6月30日`,后续只能在纯真网`注册审核后`进行`下载`,纯真网公告`2024年10月`停止下载)

`https://www.cz88.com/geo-public`

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance94

Actively maintained with recent releases

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 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 ~335 days

Total

3

Last Release

33d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/cfdd63860bdbf00d57b0f2dcc9c4f9816d9d790b5a22ce30516681d748d2abd4?d=identicon)[hulangfy@163.com](/maintainers/hulangfy@163.com)

---

Top Contributors

[![hulang](https://avatars.githubusercontent.com/u/4961831?v=4)](https://github.com/hulang "hulang (45 commits)")

---

Tags

databaseIPlocationChineseChina

### Embed Badge

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

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

###  Alternatives

[itbdw/ip-database

IP数据库 IPV4 IPV6（解析为国家、省、市、县、运营商）

1.5k126.6k7](/packages/itbdw-ip-database)[doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.

9.7k605.0M6.8k](/packages/doctrine-dbal)[doctrine/orm

Object-Relational-Mapper for PHP

10.2k300.5M7.5k](/packages/doctrine-orm)[doctrine/doctrine-bundle

Symfony DoctrineBundle

4.8k254.4M4.1k](/packages/doctrine-doctrine-bundle)[doctrine/migrations

PHP Doctrine Migrations project offer additional functionality on top of the database abstraction layer (DBAL) for versioning your database schema and easily deploying changes to it. It is a very easy to use and a powerful tool.

4.8k217.3M548](/packages/doctrine-migrations)[doctrine/data-fixtures

Data Fixtures for all Doctrine Object Managers

2.9k143.6M586](/packages/doctrine-data-fixtures)

PHPackages © 2026

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