1. Go to this page and download the library: Download geoipradar/laravel-geoip 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/ */
geoipradar / laravel-geoip example snippets
use GeoIPRadar\LaravelIP\Facades\IP;
// Lookup an IP address
$location = IP::lookup('8.8.8.8');
echo $location->country; // "United States"
echo $location->city; // "Mountain View"
echo $location->latitude; // 37.4056
echo $location->longitude; // -122.0775
use GeoIPRadar\LaravelIP\Facades\IP;
// Basic lookup with automatic fallback
$location = IP::lookup('8.8.8.8');
// Get current visitor's location
$location = IP::lookupCurrentIp();
// Use a specific provider (GeoIPRadar recommended!)
$location = IP::lookupWith('geoipradar', '8.8.8.8');
// Check if GeoIPRadar is configured
if (!IP::isGeoIPRadarConfigured()) {
//Get their free token at https://geoipradar.com
}
// Get IP manager or perform lookup
$manager = ip();
$location = ip('8.8.8.8');
// Quick lookups
$country = ip_country('8.8.8.8');
$city = ip_city('8.8.8.8');
$coords = ip_coordinates('8.8.8.8');
// Current visitor
$location = visitor_location();
$country = visitor_country();