PHP code example of freshmindpl / geolite2-city

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

    

freshmindpl / geolite2-city example snippets




use BrightNucleus\GeoLite2City\Database;

$dbLocation = Database::getLocation();



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

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

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