PHPackages                             workbunny/webman-ip-attribution - 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. workbunny/webman-ip-attribution

ActiveLibrary

workbunny/webman-ip-attribution
===============================

Webman plugin workbunny/webman-ip-attribution.

1.0.12(1y ago)272.5k—0%4[1 issues](https://github.com/workbunny/webman-ip-attribution/issues)MITPHPPHP &gt;=7.4CI passing

Since Sep 16Pushed 1y agoCompare

[ Source](https://github.com/workbunny/webman-ip-attribution)[ Packagist](https://packagist.org/packages/workbunny/webman-ip-attribution)[ RSS](/packages/workbunny-webman-ip-attribution/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (14)Used By (0)

[![workbunny](https://camo.githubusercontent.com/e2b1164338390ab45783434659e3e419e0c3b50fbe140c697ba1f82f59015ad6/68747470733a2f2f6368617a366368657a2e636e2f696d616765732f776f726b62756e6e792d6c6f676f2e706e67)](https://camo.githubusercontent.com/e2b1164338390ab45783434659e3e419e0c3b50fbe140c697ba1f82f59015ad6/68747470733a2f2f6368617a366368657a2e636e2f696d616765732f776f726b62756e6e792d6c6f676f2e706e67)

**workbunny/webman-ip-attribution**

**🐇 Webman plugin for IP attribution query. 🐇**

Webman plugin for IP attribution query.
=======================================

[](#webman-plugin-for-ip-attribution-query)

 [ ![Build Status](https://github.com/workbunny/webman-ip-attribution/actions/workflows/CI.yml/badge.svg) ](https://github.com/workbunny/webman-ip-attribution/actions) [ ![Latest Stable Version](https://camo.githubusercontent.com/692fc05312a3cdb826217e7aa4a1f9b6a5b61ccc0ffee5ce362cd47179ae3a9f/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f762f776f726b62756e6e792f7765626d616e2d69702d6174747269627574696f6e2f6c6174657374) ](https://github.com/workbunny/webman-ip-attribution/releases) [ ![PHP Version Require](https://camo.githubusercontent.com/c0ffc5f448baa8ecfcd55dea3d18d0374f9dce43c7021a051cae4c79c10aa2dc/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f7068702f776f726b62756e6e792f7765626d616e2d69702d6174747269627574696f6e) ](https://github.com/workbunny/webman-ip-attribution/blob/main/composer.json) [ ![GitHub license](https://camo.githubusercontent.com/7ed444cbbad5e31e4127665b15637b7d4e680fcd84dddcf592c5a3b5e9bc81cf/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f6c6963656e73652f776f726b62756e6e792f7765626d616e2d69702d6174747269627574696f6e) ](https://github.com/workbunny/webman-ip-attribution/blob/main/LICENSE)

简介
--

[](#简介)

- 该插件自带ip本地库，存放于`/database`； 最后更新时间：2025-03 **(空了就时不时更新一下)**
    - **注：由于db文件比较大，强烈建议外载**
        1. 至  注册账号
        2. 进入下载页面下载对应db文件
- `webman-ip-attribution` 是基于`geoip2`作为底层，依托 `mmdb数据库` 查询ip归属地及asn信息
- 本项目基于[geoip2/geoip2](https://github.com/maxmind/GeoIP2-php)，感谢[MaxMind](https://github.com/maxmind) 工作组的开源

安装
--

[](#安装)

```
composer require workbunny/webman-ip-attribution
```

使用
--

[](#使用)

### 配置

[](#配置)

#### 1. 在Webman中使用app.php

[](#1-在webman中使用appphp)

**注：配置可选填**

```
return [
    'enable' => true,

    'default'  => '--',      // 缺省展示值
    'language' => ['zh-CN'], // 语言

    'db-country' => null,    // 自定义的country库绝对地址
    'db-city'    => null,    // 自定义的city库绝对地址
    'db-asn'     => null,    // 自定义的asn库绝对地址
];
```

#### 2. 在php-fpm中使用

[](#2-在php-fpm中使用)

**注：配置可选填**

```
use Workbunny\WebmanIpAttribution\Location;

$location = new Location([
    'default'  => '--',      // 缺省展示值
    'language' => ['zh-CN'], // 语言
    'db-country' => null,    // 自定义的country库绝对地址
    'db-city'    => null,    // 自定义的city库绝对地址
    'db-asn'     => null,    // 自定义的asn库绝对地址
]);
```

### 快速获取

[](#快速获取)

```
use Workbunny\WebmanIpAttribution\Location;
use Workbunny\WebmanIpAttribution\Exceptions\IpAttributionException

try {
     $location = new Location();
     var_dump($location->getLocation('8.8.8.8')); // ipv4
     var_dump($location->getLocation('::0808:0808')); // ipv6
//     [
//         'country' => 'United States',
//         'city' => '--',
//         'asn' => 'GOOGLE',
//         'continent' => 'North America',
//         'timezone' => 'America/Chicago',
//     ]
 }catch (IpAttributionException $exception){

 }
```

### 使用city库查询

[](#使用city库查询)

**注：City库包含了 大洲、国家、城市，但不包含网络运营商等相关信息**

```
use Workbunny\WebmanIpAttribution\Location;
use Workbunny\WebmanIpAttribution\Exceptions\IpAttributionException

try {
   $location = new Location();
    var_dump($location->city('8.8.8.8')); // ipv4
    var_dump($location->city('::0808:0808')); // ipv6
    // 返回 GeoIp2\Model\City 对象

 }catch (IpAttributionException $exception){

 }
```

### 使用country库查询

[](#使用country库查询)

**注：Country库不包含城市及网络运营商等信息，通常使用City库即可，Country存在的意义在于较于City更轻**

```
use Workbunny\WebmanIpAttribution\Location;
use Workbunny\WebmanIpAttribution\Exceptions\IpAttributionException

try {
   $location = new Location();
    var_dump($location->country('8.8.8.8')); // ipv4
    var_dump($location->country('::0808:0808')); // ipv6
    // 返回 GeoIp2\Model\Country 对象

 }catch (IpAttributionException $exception){

 }
```

### 使用asn库查询

[](#使用asn库查询)

**注：Asn库仅包含网络运营商等相关信息**

```
use Workbunny\WebmanIpAttribution\Location;
use Workbunny\WebmanIpAttribution\Exceptions\IpAttributionException

try {
   $location = new Location();
    var_dump($location->asn('8.8.8.8')); // ipv4
    var_dump($location->asn('::0808:0808')); // ipv6
    // 返回 GeoIp2\Model\Asn 对象

 }catch (IpAttributionException $exception){

 }
```

### 使用原始Reader操作

[](#使用原始reader操作)

**注：原始Reader可以直接使用 [geoip2/geoip2](https://github.com/maxmind/GeoIP2-php) 提供的方法操作相关的库**

```
use Workbunny\WebmanIpAttribution\Location;

$location = new Location();
var_dump($location->createReader(Location::DB_CITY)); // City库
// 返回连接City库的 GeoIp2\Database\Reader 对象
var_dump($location->createReader(Location::DB_ASN)); // ASN库
// 返回连接ASN库的 GeoIp2\Database\Reader 对象
var_dump($location->createReader(Location::DB_ASN)); // Country库
// 返回连接Country库的 GeoIp2\Database\Reader 对象
```

更多用法和示例参照 [geoip2/geoip2](https://github.com/maxmind/GeoIP2-php)；

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance45

Moderate activity, may be stable

Popularity30

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 81.3% 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 ~77 days

Recently: every ~190 days

Total

13

Last Release

413d ago

### Community

Maintainers

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

---

Top Contributors

[![chaz6chez](https://avatars.githubusercontent.com/u/22535862?v=4)](https://github.com/chaz6chez "chaz6chez (39 commits)")[![sunsgneayo](https://avatars.githubusercontent.com/u/51745500?v=4)](https://github.com/sunsgneayo "sunsgneayo (8 commits)")[![bilulanlv](https://avatars.githubusercontent.com/u/90918529?v=4)](https://github.com/bilulanlv "bilulanlv (1 commits)")

---

Tags

geolite2phpwebmanworkbunny

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/workbunny-webman-ip-attribution/health.svg)

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

###  Alternatives

[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.4k37.3k](/packages/matomo-matomo)[stevebauman/location

Retrieve a user's location by their IP Address

1.3k7.6M65](/packages/stevebauman-location)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[shlinkio/shlink

A self-hosted and PHP-based URL shortener application with CLI and REST interfaces

4.8k4.3k](/packages/shlinkio-shlink)[nnjeim/world

Laravel countries, states, cities, currencies, languages and IP geolocation

970361.2k3](/packages/nnjeim-world)[pulkitjalan/ip-geolocation

IP Geolocation Wrapper with Laravel Support

89164.9k1](/packages/pulkitjalan-ip-geolocation)

PHPackages © 2026

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