mallka / easygeo
wrapper of geolite2 city/asn and support update db file
v1.0
2021-03-16 15:43 UTC
Requires
- maxmind-db/reader: ~1.0
- tronovav/geoip2-update: ^1.2
README
features
- Update ip db file
- Wrapper of geolite city & asn , it will return an array include city & asn info.
Update ip db file
Get your licenser_key from your maxmind account.and then run the code as bellow
<?php
use mallka\easygeo\Geo;
\mallka\easygeo\Geo::update('Your key','/path/to/your_db_floder');
Get extra info of ip
<?php
use mallka\easygeo\Geo;
$res = \mallka\easygeo\Geo::getInfo('113.110.215.242','./store/GeoLite2-City.mmdb','./store/GeoLite2-ASN.mmdb',$lang='zh-CN');
$res = json_encode($res);
/**
$res will display as bellow:
{
"city":"深圳市",
"continent":"亚洲",
"country":"中国",
"registered_country":"中国",
"province":"广东",
"country_code":"CN",
"province_code":"GD",
"location"":{
"accuracy_radius":5,
"latitude":22.5333,
"longitude":114.1333,
"time_zone":"Asia/Shanghai"
},
"autonomous_system_number""":"AS4134",
"organization"":"ASChinanet"
}
**/
How to install
via composer
composer require mallka/easygeo
via direct download
- download the file (include file)
- set floder permissions to 777 for store floder when you on linux ,like chmod -Rf 777 store
- use it or learn it from test.php
thanks :
- tronovav/geoip2-update
- maxmind-db/reader