gai871013 / ip-location
纯真IP地址,composer包(解析QQWay.dat)
Installs: 4 861
Dependents: 4
Suggesters: 0
Security: 0
Stars: 73
Watchers: 2
Forks: 15
Open Issues: 1
Requires
- php: >7.0
- ext-json: >0
Requires (Dev)
- mockery/mockery: ^1.2
- phpunit/phpunit: ^7.0|^8.0|^9.0
- dev-master
- 1.1.240509
- 1.1.240424
- 1.1.240320
- 1.1.240313
- 1.1.240306
- 1.1.240214
- 1.1.240124
- 1.1.240117
- 1.1.240110
- 1.1.240103
- 1.1.231227
- 1.1.231220
- 1.1.231213
- 1.1.231206
- 1.1.231122
- 1.1.231115
- 1.1.231101
- 1.1.231023
- 1.1.231018
- 1.1.231011
- 1.1.231004
- 1.1.230920
- 1.1.230802
- 1.1.230712
- 1.1.230628
- 1.1.230614
- 1.1.230607
- 1.1.230517
- 1.1.230503
- 1.1.230426
- 1.1.230419
- 1.1.230412
- 1.1.230405
- 1.1.230322
- 1.1.230222
- 1.1.230215
- 1.1.230208
- 1.1.230201
- 1.1.230111
- 1.1.230104
- 1.1.221221
- 1.1.221216
- 1.1.221207
- 1.1.221123
- 1.1.221116
- 1.1.221109
- 1.1.221102
- 1.1.221026
- 1.1.221019
- 1.1.221012
- 1.1.220615
- 1.1.220608
- 1.1.220420
- 1.1.220413
- 1.1.220330
- 1.1.220316
- 1.1.220302
- 1.1.220223
- 1.1.220216
- 1.1.220119
- 1.1.220112
- 1.1.211222
- 1.1.211215
- 1.1.211201
- 1.1.211124
- 1.1.211110
- 1.1.211103
- 1.1.211027
- 1.1.211020
- 1.1.211006
- 1.1.210908
- 1.1.210901
- 1.1.210825
- 1.1.210818
- 1.1.210811
- 1.1.210804
- 1.1.210728
- 1.1.210721
- 1.1.210714
- 1.1.210707
- 1.1.210630
- 1.1.210623
- 1.1.210616
- 1.1.210609
- 1.1.210602
- 1.1.210526
- 1.1.210519
- 1.1.210512
- 1.1.210506
- 1.1.210428
- 1.1.210421
- 1.1.210415
- 1.1.210331
- 1.1.210324
- 1.1.210318
- 1.1.210310
- 1.1.210304
- 1.1.210218
- 1.1.210210
- 1.1.210202
- 1.1.210127
- 1.1.210120
- 1.1.210112
- 1.1.201219
- 1.1.201215
- 1.1.201210
- 1.1.201205
- 1.1.201130
- 1.1.201125
- 1.1.201120
- 1.1.201115
- 1.1.201110
- 1.1.201105
- 1.1.201102
- 1.1.201025
- 1.1.201020
- 1.1.201010
- 1.1.200925
- 1.1.200921
- 1.1.200915
- 1.1.200830
- 1.1.200825
- 1.1.200821
- 1.1.200815
- 1.1.200811
- 1.1.200806
- 1.1.200803
- 1.1.4
- 1.1.3
- 1.1.0
- 1.0.13
- 1.0.12
- 1.0.11
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
This package is auto-updated.
Last update: 2024-11-22 02:51:55 UTC
README
纯真IP地址库,composer包(解析QQWry.dat).
记录总数:628031条 更新日期:2024年05月08日
安装
$ composer require gai871013/ip-location -vvv
使用方式
在Laravel中使用
1.在 config/app.php
注册 ServiceProvider 和 Facade (Laravel 5.5 + 无需手动注册)
<?php ['providers' => [ // ... Gai871013\IpLocation\ServiceProvider::class, ], 'aliases' => [ // ... 'IpLocation' => Gai871013\IpLocation\Facades\IpLocation::class, ], ];
2.使用:
<?php use Gai871013\IpLocation\Facades\IpLocation; // ... dump(app('IpLocation')->getLocation('www.wc87.com')); dd(IpLocation::getLocation('8.8.4.4')); array( "ip" => "101.200.45.167", "beginip" => "101.200.0.0", "endip" => "101.201.255.255", "country" => "北京市", "area" => "阿里云BGP数据中心", ); array( "ip" => "8.8.4.4", "beginip" => "8.8.4.4", "endip" => "8.8.4.4", "country" => "美国", "area" => "加利福尼亚州圣克拉拉县山景市谷歌公司DNS服务器", ); // ...
基本使用
<?php use Gai871013\IpLocation\IpLocation; $ipLocation = new IpLocation(); // url $url = 'https://www.baidu.com'; $ip = '127.0.0.1'; // 使用域名国家&运营商 $result = $ipLocation->getLocation($url); dump($result); array( "ip" => "61.135.169.125", "beginip" => "61.135.169.0", "endip" => "61.135.169.255", "country" => "北京市", "area" => "北京百度网讯科技有限公司联通节点", ); // 使用IP地址国家&运营商 $result = $ipLocation->getLocation($ip); dump($result); array( "ip" => "127.0.0.1", "beginip" => "127.0.0.1", "endip" => "127.0.0.1", "country" => "本机地址", "area" => "", ) ?>
<?php # ipip $path = 'path-to-ipdb.ipdb' || null; $city = new Gai871013\IpLocation\ipip\db\City($path); var_dump($city->find('118.28.1.1')); var_dump($city->find('8.8.8.8')); var_dump($city->find('127.0.0.1'));
Contributing
You can contribute in one of three ways:
- File bug reports using the issue tracker.
- Answer questions or fix bugs on the issue tracker.
- Contribute new features or update the wiki.
The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable.
License
MIT