PHP code example of shlinkio / shlink-ip-geolocation

1. Go to this page and download the library: Download shlinkio/shlink-ip-geolocation 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/ */

    

shlinkio / shlink-ip-geolocation example snippets


/**
 * @throws WrongIpException
 */
public function resolveIpLocation(string $ipAddress): Model\Location;

public function databaseFileExists(): bool;

/**
 * @throws RuntimeException
 */
public function downloadFreshCopy(?callable $handleProgress = null): void;


declare(strict_types=1);

return [

    'geolite2' => [
        // Mandatory options
        'db_location' => __DIR__ . '/../../data/GeoLite2-City.mmdb',
        'temp_dir' => sys_get_temp_dir(),

        // Optional options
        'license_key' => 'kjhk45hkj34fdwe5', // If not set, no attempts to download the file will happen
    ],

];