PHP code example of brightnucleus / geolite2-country

1. Go to this page and download the library: Download brightnucleus/geolite2-country 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/ */

    

brightnucleus / geolite2-country example snippets




use BrightNucleus\GeoLite2Country\Database;

$dbLocation = Database::getLocation();



use GeoIp2\Database\Reader;
use BrightNucleus\GeoLite2Country\Database;

function getCountry($ip) {
    $dbLocation = Database::getLocation();
    $reader = new Reader($dbLocation);

    return $reader->country($ip);
}