myweishanli/yii2-ip2location

Yii2 Ip to Location

Installs: 1 661

Dependents: 2

Suggesters: 0

Security: 0

Stars: 32

Watchers: 2

Forks: 6

Type:yii2-extension

1.0.0 2016-05-17 04:48 UTC

This package is not auto-updated.

Last update: 2024-11-04 02:57:49 UTC


README

安装

安装这个扩展的首选方式是通过 composer.

执行

composer require --prefer-dist myweishanli/yii2-ip2location

或添加

"myweishanli/yii2-ip2location": "~1.0.0"

根据IP查询

use \wsl\ip2location\Ip2Location;

$ipLocation = new Ip2Location();
$locationModel = $ipLocation->getLocation('8.8.8.8');
print_r($locationModel->toArray());
// Array
// (
//     [ip] => 8.8.8.8
//     [begin_ip] => 8.8.8.8
//     [end_ip] => 8.8.8.8
//     [country] => 美国
//     [area] => 加利福尼亚州圣克拉拉县山景市谷歌公司DNS服务器
// )

升级数据库

use \wsl\ip2location\QQWry;

$qqwry = new QQWry();
$qqwry->upgrade();