PHPackages                             iplocation/local - 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. iplocation/local

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

iplocation/local
================

get the ip's location info with Chinese

1.0.2(6y ago)027MITPHP

Since Jul 15Pushed 6y agoCompare

[ Source](https://github.com/WhiteCrowSource/iplocation)[ Packagist](https://packagist.org/packages/iplocation/local)[ RSS](/packages/iplocation-local/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

Ip Location Zh
==============

[](#ip-location-zh)

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/bb62337c5afc39a81be04ea7c7cb190b67f7313de909d2a66d144e6f39efaf40/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7a68757a68696368616f2f69702d6c6f636174696f6e2d7a682f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/zhuzhichao/ip-location-zh/?branch=master)[![Build Status](https://camo.githubusercontent.com/d2d7475460efc8784a86d132de3841fade7c554f50149c492d1190c39c44edbc/68747470733a2f2f6170692e7472617669732d63692e6f72672f7a68757a68696368616f2f69702d6c6f636174696f6e2d7a682e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/zhuzhichao/ip-location-zh)

源自 感谢原作者。

重命名了空间名称（应用在项目中显得正式点），增加了location方法方便直接输出地址

数据源于: 最后更新时间：20190703 免费版数据不含运营商，国外只具体到国家 数据是請自行下載替換data.ipdb（免费版本）

简单的解析IP地址位置，例如通过 ip：`171.12.10.156` 可以获得是 `中国河南郑州`，以及中国行政区划代码(支持到市级), 同样能获得国外的地址，但是没有国内详细。

> 注意: 该免费数据库不提供经纬度、运营商、行政区等更详细的内容, 如果你有更多的需求可以考虑使用他们的收费服务。本包的目的是提供给需求简单, 手里没钱的程序员或者老板不舍得掏钱来获取定时更新的IP信息

> 国家码和邮编不是该包负责的内容, 需自行构建相关的程序

特点
--

[](#特点)

1. 不配置和使用数据库，妈妈再也不用担心配置问题了
2. 使用简单，功能专（dān）注（yī）
3. 使用 [composer](https://getcomposer.org/) 进行安装管理，国际标准，方便快捷，即安即用，随时更新数据库

Install
-------

[](#install)

这里不详细介绍安装 composer 了，大家根据 [链接](https://getcomposer.org/) 自行安装吧！

`composer require "iplocation/local"`

Usage
-----

[](#usage)

#### Common

[](#common)

可以这样来用

```
require 'vendor/autoload.php';  
use IpLocation\local\Ip;  
var_dump(Ip::find('171.12.10.156'));//输出数组

var_dump(Ip::location('171.12.10.156')); //直接输出地址
```

```
// 返回结果
array (size=4)
  0 => string '中国' (length=6)
  1 => string '河南' (length=6)
  2 => string '郑州' (length=6)
  3 => string '' (length=0)
  4 => string '410100' (length=6)
----------------------------------
string '河南郑州'

```

#### Laravel

[](#laravel)

对于`laravel`可以这样优雅的用:

1.安装该插件

2.在 `config/app.php`(Laravel 5.0 - 5.4)添加下面的代码，如果是 Laravel 5.5+ ，已经支持扩展包发现，不需要添加下面的代码

```
// Laravel 5.5 不需要添加
'aliases' => [
    'Ip'  => 'IpLocation\ZhCN\Ip', 
],
```

3.然后开始在你的项目里面使用了 `Ip::find('171.12.10.156')` 或 `Ip::find(Request::getClientIp())``Ip::location('171.12.10.156')` 或 `Ip::location(Request::getClientIp())`

**对，很简单， `find`输出数组，`location`输出拼接好的字符串**

Contributing
------------

[](#contributing)

有什么新的想法和建议，欢迎提交 [issue](https://github.com/zhuzhichao/ip-location-zh/issues) 或者 [Pull Requests](https://github.com/zhuzhichao/ip-location-zh/pulls) 。

License
-------

[](#license)

MIT

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity60

Established project with proven stability

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

Total

2

Last Release

2496d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a05e4a50a95d4958f1e1761399a1100c627b551a5d6eba3c4ef1bb04854809ac?d=identicon)[wxyhhy911](/maintainers/wxyhhy911)

---

Top Contributors

[![WhiteCrowSource](https://avatars.githubusercontent.com/u/8186205?v=4)](https://github.com/WhiteCrowSource "WhiteCrowSource (5 commits)")

---

Tags

IPlocationChinese

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/iplocation-local/health.svg)

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

###  Alternatives

[stevebauman/location

Retrieve a user's location by their IP Address

1.3k7.6M65](/packages/stevebauman-location)[zhuzhichao/ip-location-zh

get the ip's location info with Chinese

617212.5k11](/packages/zhuzhichao-ip-location-zh)[itbdw/ip-database

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

1.5k123.8k7](/packages/itbdw-ip-database)[gai871013/ip-location

纯真IP地址,composer包(解析QQWay.dat)

729.7k4](/packages/gai871013-ip-location)[kartik-v/yii2-ipinfo

An IP address information display widget for Yii 2.0 with country flag and geo position info.

2832.6k1](/packages/kartik-v-yii2-ipinfo)[tastaturberuf/anystores

Location management and geographic search

121.7k](/packages/tastaturberuf-anystores)

PHPackages © 2026

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