1. Go to this page and download the library: Download brainstud/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/ */
return [
'header' => 'CF-IPCountry', // The cloudflare header that contains the country code
'geocoder' => GeoLocator::IpRegistry, // The geocoder to use if the header is empty
'ip-registry' => [ // Credentials for the ip registry API
'base_url' => env('IP_REGISTRY_URL', 'https://api.ipregistry.co'),
'key' => env('IP_REGISTRY_KEY'),
],
'ip-stack' => [ // Credentials for the ip stack API
'base_url' => env('IP_STACK_URL', 'https://api.ipstack.com'),
'key' => env('IP_STACK_KEY'),
],
'cache_ttl' => DateInterval::createFromDateString('2 months'), // Cache TTL for the geocoder services.
];