zertex / yii2-zx-geoip-country
Yii 2 GeoIP extension. Returns country of current or specified IP (uses MaxMind's GeoIP2 databases)
Installs: 9
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- php: >=5.4.0
- maxmind-db/reader: ~1.0
- yiisoft/yii2: >=2.0.0
- zertex/yii2-zx-country-db: *
Requires (Dev)
- phpunit/phpunit: ~4.4
This package is not auto-updated.
Last update: 2024-11-09 20:56:25 UTC
README
Provides information about country of user by IP address.
Currently available:
- Country
- Country ISO Code
Install
Run
$ php composer.phar require zertex/yii2-zx-geoip-country "~1.0"
OR
add to your composer.json
{ "require": { "zertex/yii2-zx-geoip-country": "~1.0" } }
and run
$ php composer update
Usage
Like component
<?php $config = [ ... 'components' => [ 'geoip' => ['class' => 'zertex\GeoIP\GeoIP'], ] ... ];
somewhere in code
$ip = Yii::$app->geoip->ip(); // current user ip $ip = Yii::$app->geoip->ip("111.111.111.111"); $ip->country; // "United States"
Like object directly somewhere in your application
$geoip = new \zertex\GeoIP\GeoIP(); $ip = $geoip->ip("111.111.111.111"); $ip->country; // "United States"
This product includes GeoLite2 data created by MaxMind, available from http://www.maxmind.com