PHPackages                             tim168/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. tim168/ip

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

tim168/ip
=========

A IP SDK

1.1.1(5y ago)25661MITPHPPHP &gt;=5.6CI failing

Since Mar 28Pushed 5y ago2 watchersCompare

[ Source](https://github.com/TIM168/Ip)[ Packagist](https://packagist.org/packages/tim168/ip)[ RSS](/packages/tim168-ip/feed)WikiDiscussions master Synced 1mo ago

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

 Ip
====

[](#-ip-)

 根据IpV4、IpV6地址获取定位信息的PHP组件

[![Build Status](https://camo.githubusercontent.com/6546be86f28d623c5207c73fb845c6292d60f21731b6878506d0546a5271ba6e/68747470733a2f2f7472617669732d63692e6f72672f54494d3136382f49702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/TIM168/Ip)[![Latest Stable Version](https://camo.githubusercontent.com/3bec0a911baf813470391a9193a8c4bc43bd864f07c5aff23a17e21df10ac2ca/68747470733a2f2f706f7365722e707567782e6f72672f74696d3136382f69702f762f737461626c65)](https://packagist.org/packages/tim168/ip)[![License](https://camo.githubusercontent.com/6d855063a2ef0a72c6d855dffaaaa6b66919733ff7aad1067e7005341692fc56/68747470733a2f2f706f7365722e707567782e6f72672f74696d3136382f69702f6c6963656e7365)](https://packagist.org/packages/tim168/ip)[![Latest Unstable Version](https://camo.githubusercontent.com/cd8b42a04fbe3707e1ebf4b42301280ff375e3c3fd58c96fbd385fd9f63381a4/68747470733a2f2f706f7365722e707567782e6f72672f74696d3136382f69702f762f756e737461626c65)](https://packagist.org/packages/tim168/ip)[![Total Downloads](https://camo.githubusercontent.com/74d51b02961943626b3723d72b650fb79c2bf40716b25b0040106036fbb5c8dd/68747470733a2f2f706f7365722e707567782e6f72672f74696d3136382f69702f646f776e6c6f616473)](https://packagist.org/packages/tim168/ip)[![composer.lock](https://camo.githubusercontent.com/072d2696f414293078217fa79dd44a7c6b793dac185fcbaa63b2ad5c5a169cc3/68747470733a2f2f706f7365722e707567782e6f72672f74696d3136382f69702f636f6d706f7365726c6f636b)](https://packagist.org/packages/tim168/ip)[![](https://camo.githubusercontent.com/d1f5a756cc28c298996148c17e2e8370b07d260f31012dc7f5f18e4ccc39ae22/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344352e362d626c7565)](https://www.php.net/)

README: [中文](https://github.com/TIM168/Ip/blob/master/README.md "中文")/[English](https://github.com/TIM168/Ip/blob/master/README-en.md "English")

安装
--

[](#安装)

```
$ composer require tim168/ip
```

使用
--

[](#使用)

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

use Tim168\Ip\Ip;

```

支持的语言格式
-------

[](#支持的语言格式)

字符集描述en英语de德语es西班牙语pt-BR葡语fr法语ja日语zh-CN中文ru俄语获取Ip定位信息
--------

[](#获取ip定位信息)

```
$res = Ip::getIp('json','116.234.222.36')

```

示例
--

[](#示例)

```
{
	"status": "success", //状态success或fail
	"country": "中国",   //国家
	"countryCode": "CN", //国家代码
	"region": "SH",      //省份简称
	"regionName": "上海",//省份
	"city": "上海",	   //城市
	"zip": "",           //邮编
	"lat": 31.0449,      //纬度
	"lon": 121.4012,	 //经度
	"timezone": "Asia/Shanghai", //时区
	"isp": "China Telecom (Group)", //运营商
	"org": "Chinanet SH",  //组织
	"as": "AS4812 China Telecom (Group)", //BGP机房
	"query": "116.234.222.36" //ip
}

```

获取XML格式
-------

[](#获取xml格式)

```
$res = Ip::getIp('xml','116.234.222.36')

```

示例
--

[](#示例-1)

```

	success
	中国
	CN
	SH
	上海
	上海

	31.0449
	121.4012
	Asia/Shanghai
	China Telecom (Group)
	Chinanet SH
	AS4812 China Telecom (Group)
	116.234.222.36

```

获取CSV格式
-------

[](#获取csv格式)

```
$res = Ip::getIp('csv','116.234.222.36')

```

示例
--

[](#示例-2)

```
success,中国,CN,SH,上海,上海,,31.0449,121.4012,Asia/Shanghai,China Telecom (Group),Chinanet SH,AS4812 China Telecom
(Group),116.234.222.36

```

获取序列化格式
-------

[](#获取序列化格式)

```
$res = Ip::getIp('php','116.234.222.36')

```

示例
--

[](#示例-3)

```
a:14:{s:6:"status";s:7:"success";s:7:"country";s:6:"中国";s:11:"countryCode";s:2:"CN";s:6:"region";s:2:"SH";s:10:"regionName";s:6:"上海";s:4:"city";s:6:"上海";s:3:"zip";s:0:"";s:3:"lat";d:31.0449;s:3:"lon";d:121.4012;s:8:"timezone";s:13:"Asia/Shanghai";s:3:"isp";s:21:"China
Telecom (Group)";s:3:"org";s:11:"Chinanet SH";s:2:"as";s:28:"AS4812 China Telecom
(Group)";s:5:"query";s:14:"116.234.222.36";}

```

IpV4转换成IpV6
-----------

[](#ipv4转换成ipv6)

```
$res = Ip::IpV4toV6('116.234.222.36')

```

示例
--

[](#示例-4)

```
0000:0000:0000:0000:0000:ffff:74ea:de24

```

IpV6转换成IpV4
-----------

[](#ipv6转换成ipv4)

```
$res = Ip::IpV6toV4('0000:0000:0000:0000:0000:ffff:74ea:de24')

```

示例
--

[](#示例-5)

```
116.234.222.36

```

License
-------

[](#license)

**MIT**

后语
--

[](#后语)

#### 欢迎Star

[](#欢迎star)

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity53

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

Total

3

Last Release

2146d ago

### Community

Maintainers

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

---

Top Contributors

[![suppermoment](https://avatars.githubusercontent.com/u/67251942?v=4)](https://github.com/suppermoment "suppermoment (15 commits)")

---

Tags

ipipv4ipv4-addressipv6laravelphptpyii

### Embed Badge

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

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

###  Alternatives

[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)[dhlparcel/magento2-plugin

DHL Parcel plugin for Magento 2

11180.5k2](/packages/dhlparcel-magento2-plugin)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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