ip2location - 获取 IP 地址的真实地理位置
ip2location - 获取 IP 地址的真实地理位置
PHP 地理位置
共3Star
详细介绍
ip2location
功能
通过 IP,获取该 IP 所在的位置,例如通过 ip:27.196.21.222
可以获得 中国山东聊城
。
IP 数据库更新于:2018年07月02日,数据来源于 http://www.ipip.net/ ,IP 数据库由 ipip.net 所有,本项目仅供 php 项目 composer 安装方便使用。
特点
- 不依赖数据库,使用 DATX 格式数据,查询性能高效
- 使用简单,功能专注
- 使用 composer 进行安装管理,方便快捷,随时更新数据库
Install
composer require xdstack/ip2location
Usage
使用方法超级简单,只有两个方法,find
和 location
。find 返回数组形式的结果,location 返回字符串形式的结果。
非 Laravel:
<?php
require 'vendor/autoload.php';
use xdstack\ip2location\Ip;
var_dump(Ip::find('27.196.21.222'));
返回结果
array(4) {
[0] => string(6) "中国"
[1] => string(6) "山东"
[2] => string(6) "聊城"
[3] => string(0) ""
}
Laravel:
Ip::find('27.196.21.222')
或 Ip::find(Request::getClientIp())
Contributing
有什么新的想法和建议,欢迎提交 issue 或者 Pull Requests 。
License
MIT
-
6 Star
-
664 Star
-
597 Star
-
0 Star
-
3 Star
-
23 Star
-
388 Star
-
46 Star
-
14 Star
-
20 Star