dpodium/yii2-geoip-city-db
最新稳定版本:1.1
Composer 安装命令:
composer require dpodium/yii2-geoip-city-db
包简介
Yii2 Component to allow for easy usage of the MaxMind Free dbs.
README 文档
README
Yii2 Component to allow for easy usage of the MaxMind Free dbs.
Based on package phiphi1992/Yii2-GeoIP by Phi Hoang Xuan.
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require dpodium/yii2-geoip-city-db "~0.2"
or add
"dpodium/yii2-geoip-city-db "~0.2"
to the require section of your composer.json file.
Component Setup
Once the extension is installed, simply modify your application configuration as follows:
return [ 'components' => [ ... 'geoip' => [ 'class' => 'dpodium\yii2\geoip\components\CGeoIP', ], ... ], ... ];
If querying only partial Country data is required, yii2-geoip can be used instead and is lighter in terms of repo size, see dpodium/yii2-geoip.
For more information on the data availability, see below.
Usage
All methods accept an IP address as an argument. If no argument is supplied Yii::$app->getRequest()->getUserIP() is used.
//Along with free DB
$location = Yii::$app->geoip->lookupLocation();
$countryCode = Yii::$app->geoip->lookupCountryCode();
$countryName = Yii::$app->geoip->lookupCountryName();
Location attributes:
$location->countryCode //Available in both Country and City DB
$location->countryName //Available in both Country and City DB
$location->continentCode //Available in both Country and City DB
$location->continentName //Available in both Country and City DB
$location->city //Available in only City DB
$location->postalCode //Available in only City DB
$location->latitude //Available in only City DB
$location->longitude //Available in only City DB
$location->timeZone //Available in only City DB
统计信息
- 总下载量: 17.84k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-06-12