PHPackages                             draguo/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. [Localization &amp; i18n](/categories/localization)
4. /
5. draguo/ip

ActiveLibrary[Localization &amp; i18n](/categories/localization)

draguo/ip
=========

通过ip返回中文地理位置

1.0.2(7y ago)0401MITPHPPHP &gt;=7.0.0

Since Mar 1Pushed 7y ago1 watchersCompare

[ Source](https://github.com/draguo/Ip)[ Packagist](https://packagist.org/packages/draguo/ip)[ RSS](/packages/draguo-ip/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (2)Versions (5)Used By (0)

通过ip获取中文地理位置
============

[](#通过ip获取中文地理位置)

[![Build Status](https://camo.githubusercontent.com/f541512371547d7bb9784e571fa3074be338e22e92ea0f282c51eb02b0934567/68747470733a2f2f7472617669732d63692e6f72672f64726167756f2f49702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/draguo/Ip)

说明
--

[](#说明)

依赖于各家提供的 api

使用
--

[](#使用)

```
$config = [
    'driver' => 'amap'
    'key' => 'qweqweqwassdf',
];

// return array
$service = new Ip($config);
$location = $service->toLocation($ip);
[
    country
    province
    city
    adcode // 城市的编号
    lng // 经度
    lat // 维度
    isp // 服务商
]
```

为了方便使用， toLocation 返回的方法进行了重新包装，但由于各家服务商提供的数据 不一致，所以部分数据会不存在，如果需要原样的数据可以调用，toLocationRaw($ip)
driver 名见下面的支持计划中黑体字部分

已经支持计划(免费使用的) 淘宝 **taobao**高德地图 **amap**百度地图 **baidu**

未来支持(没有提供免费试用 api)

- ipip.net api
- ipip.net 数据库
- 纯真数据库
- ip 问问 api
- ip 问问 数据库

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity61

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

Total

3

Last Release

2561d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/72f9a53e815a82dcedc10a1e865bc34defeed186b7a0b931d67885d6b6b251b5?d=identicon)[draguo](/maintainers/draguo)

---

Top Contributors

[![draguo](https://avatars.githubusercontent.com/u/12272760?v=4)](https://github.com/draguo "draguo (14 commits)")

---

Tags

iplocation

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.2k532.1M2.5k](/packages/aws-aws-sdk-php)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k496.1k33](/packages/neuron-core-neuron-ai)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3661.2M46](/packages/tencentcloud-tencentcloud-sdk-php)[tempest/framework

The PHP framework that gets out of your way.

2.2k31.1k12](/packages/tempest-framework)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

252.5k](/packages/eslazarev-wildberries-sdk)[files.com/files-php-sdk

Files.com PHP SDK

2478.1k](/packages/filescom-files-php-sdk)

PHPackages © 2026

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