PHPackages                             youbuwei/ip-location - 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. youbuwei/ip-location

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

youbuwei/ip-location
====================

Get IP Location on Hyperf

0.1.1(3y ago)33MITPHPPHP &gt;=8.0

Since Aug 28Pushed 3y ago1 watchersCompare

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

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

IP地址归属地/IP定位
============

[](#ip地址归属地ip定位)

[![Test](https://github.com/youbuwei/ip-location/actions/workflows/test.yml/badge.svg)](https://github.com/youbuwei/ip-location/actions/workflows/test.yml)[![Latest Version](https://camo.githubusercontent.com/fb70ddb36f017aa98a7510d9c0d37a8c1f70d66eb05852233b2c93999aa5ac55/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f796f7562757765692f69702d6c6f636174696f6e2e737667)](https://packagist.org/packages/youbuwei/ip-location)[![Php Version](https://camo.githubusercontent.com/3fe2b00a3b57acdbf9c6ee0890609712713224e8b654eff0d23e4a0ae3969828/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d2533453d382e302d627269676874677265656e2e7376673f6d61784167653d32353932303030)](https://www.php.net)[![Swoole Version](https://camo.githubusercontent.com/14982c436cbafeccf61930fab8d558cc21695db0728812b042223150adc57074/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f73776f6f6c652d2533453d342e382d627269676874677265656e2e7376673f6d61784167653d32353932303030)](https://github.com/swoole/swoole-src)[![Hyperf Version](https://camo.githubusercontent.com/0281200fed9b30bce02ec331d25443617d4c6faa9fe07866f2be7a6d2e867705/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4879706572662d2533453d332e302d627269676874677265656e2e7376673f6d61784167653d32353932303030)](https://github.com/hyperf/hyperf)[![License](https://camo.githubusercontent.com/2cd06aa36e39997dc32fe5e1dd51a9f2cc262505ba820461af04cfe9d8180dbd/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f796f7562757765692f69702d6c6f636174696f6e2e7376673f6d61784167653d32353932303030)](https://github.com/youbuwei/ip-location/blob/master/LICENSE)

安装
--

[](#安装)

```
composer require youbuwei/ip-location
bin/hyperf.php vendor:publish youbuwei/ip-location

```

配置
--

[](#配置)

### 基本配置

[](#基本配置)

默认使用了[纯真IP数据库](https://github.com/youbuwei/ip-location/releases/download/0.1.0/ip.txt)，不保证数据的准确性，可自己通过其他方式获取IP地址数据。此外还对接了几个常用的服务商，可配置使用。

将IP数据文件路径配置到`config/ip-location.php`如下位置中：

```
'cz88' => [
    'db-path' => '',
]
```

因为获取归属地依赖于外部接口，存在不可控的风险，因此设计了一个开关，可以在无可用服务时关闭归属地服务，访问影响其他业务。

```
'enable' => true,
```

通过在 `config/autoload/dependencies.php` 文件中指定使用哪个接口，默认使用 `\Youbuwei\IPLocation\Api\LocalLocation.php::class`

```
