dpodium / yii2-geoip-city-db
Yii2 Component to allow for easy usage of the MaxMind Free dbs.
Installs: 14 207
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 5
Forks: 0
Open Issues: 0
Language:Shell
Type:yii2-extension
Requires
- dpodium/yii2-geoip: ~2.0
- dev-master
- 1.0
- 0.92
- 0.91
- 0.48
- 0.47
- 0.46
- 0.45
- 0.44
- 0.43
- 0.42
- 0.41
- 0.40
- 0.39
- 0.38
- 0.37
- 0.36
- 0.35
- 0.34
- 0.33
- 0.32
- 0.31
- 0.30
- 0.29
- 0.28
- 0.27
- 0.26
- 0.25
- 0.24
- 0.23.1
- 0.23
- 0.22
- 0.21
- 0.20
- 0.19
- 0.18
- 0.17
- 0.16
- 0.15
- 0.14
- 0.13
- 0.12
- 0.11
- 0.10
- 0.9
- 0.8
- 0.7
- 0.6
- 0.5
- 0.4
- 0.3
- 0.2
- 0.1
- dev-hotfix-chingyen-sc-219847-v20240423
This package is auto-updated.
Last update: 2025-01-10 04:19:15 UTC
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