PHP code example of kubrey / maxgeo

1. Go to this page and download the library: Download kubrey/maxgeo library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

kubrey / maxgeo example snippets


php composer.phar install





use MaxmindLegacy\GeoIPCity;
use MaxmindLegacy\GeoIP;

$r = new GeoIP();
try {
    $g = $r->geoip_open('/var/www/GeoLiteCity.dat', GeoIP::GEOIP_STANDARD);
    $c = new GeoIPCity($g);
    var_dump($c->GeoIP_record_by_addr('62.221.80.241'));
    $r->geoip_close();
} catch (\Exception $ex) {
    echo $ex->getMessage();
}