PHPackages                             sunxiaozheng/laravel-ip2address - 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. sunxiaozheng/laravel-ip2address

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

sunxiaozheng/laravel-ip2address
===============================

Get location information based on IP address.

v1.1.2(7y ago)026MITPHP

Since Dec 20Pushed 7y agoCompare

[ Source](https://github.com/sunxiaozheng/laravel-ip2address)[ Packagist](https://packagist.org/packages/sunxiaozheng/laravel-ip2address)[ RSS](/packages/sunxiaozheng-laravel-ip2address/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (1)DependenciesVersions (7)Used By (0)

laravel-ip2address
==================

[](#laravel-ip2address)

> 本插件功能介绍来自百度翻译

> Get location information based on IP address

> 意思是：根据IP地址获取位置信息

- 数据总条数：470264条
- 数据更新日期：2018年10月10日
- 数据库版本：纯真

### 功能介绍：

[](#功能介绍)

1. 只需传入一个IP，即可获得该IP所在的省份、城市以及运营商等信息。
2. 拒绝使用数据库，减轻服务器压力。
3. composer安装管理，方便快捷。
4. 数据源为纯真IP数据库，更新、更全、更准确。
5. 插件名字不重要，非laravel框架也可以使用，作者是个laravel死忠粉，嘘。

### 举个栗子

[](#举个栗子)

#### 安装

[](#安装)

`composer require sunxiaozheng/laravel-ip2address`

#### 使用

[](#使用)

1. 非laravel用户

```
require 'vendor/autoload.php';

use Sunxiaozheng\Ip\Addr;

$ip = '1.86.10.173';
$param = '';
/*
 * 传入prov返回该IP所在的省份
 * 传入cy返回该IP所在的城市
 * 传入net返回该IP所在的运营商（移动、联通、电信）
 * 不传默认返回该IP所在的省份+城市
 */
var_dump(Addr::get($ip, $param));

```

2. laravel用户

- 在 app/config/app.php(Laravel 4) 或 config/app.php(Laravel 5.0 - 5.4)，或者你自定义配置的 app.php 文件内添加，如果是 Laravel 5.5 ，支持扩展包发现，不需要添加下面的代码
- Laravel 5.5 不需要添加

```
'aliases' => array(
    'Addr'  => 'Sunxiaozheng\Ip\Addr',
),

```

- 在项目中使用 `Addr::get($ip, $param)` 或 `Addr::get(Request::getClientIp(), $param)`

#### 啰嗦一句

[](#啰嗦一句)

有什么新的想法和建议，欢迎提交 issue 或者 Pull Requests 。

#### License MIT

[](#license-mit)

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity67

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

Recently: every ~53 days

Total

6

Last Release

2900d ago

Major Versions

v0.1.0 → v1.0.12017-12-20

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/25973885?v=4)[Shawn Sun](/maintainers/sunxiaozheng)[@sunxiaozheng](https://github.com/sunxiaozheng)

---

Top Contributors

[![sunxiaozheng](https://avatars.githubusercontent.com/u/25973885?v=4)](https://github.com/sunxiaozheng "sunxiaozheng (21 commits)")

---

Tags

addressiplocationaddressIPlocation

### Embed Badge

![Health badge](/badges/sunxiaozheng-laravel-ip2address/health.svg)

```
[![Health](https://phpackages.com/badges/sunxiaozheng-laravel-ip2address/health.svg)](https://phpackages.com/packages/sunxiaozheng-laravel-ip2address)
```

###  Alternatives

[stevebauman/location

Retrieve a user's location by their IP Address

1.3k8.2M84](/packages/stevebauman-location)[zoujingli/ip2region

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

1.4k462.5k65](/packages/zoujingli-ip2region)[mlocati/ip-lib

Handle IPv4, IPv6 addresses and ranges

3127.0M60](/packages/mlocati-ip-lib)[zhuzhichao/ip-location-zh

get the ip's location info with Chinese

616215.8k14](/packages/zhuzhichao-ip-location-zh)[markrogoyski/ipv4-subnet-calculator

Network calculator for subnet mask and other classless (CIDR) network information.

175839.3k13](/packages/markrogoyski-ipv4-subnet-calculator)[gai871013/ip-location

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

7210.0k4](/packages/gai871013-ip-location)

PHPackages © 2026

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