PHP code example of adrianorosa / laravel-geolocation
1. Go to this page and download the library: Download adrianorosa/laravel-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/ */
adrianorosa / laravel-geolocation example snippets
use Adrianorosa\GeoLocation\GeoLocation;
$details = GeoLocation::lookup('8.8.8.8');
echo $details->getIp();
// 8.8.8.8
echo $details->getCity();
// Mountain View
echo $details->getRegion();
// California
echo $details->getCountry();
// United States
echo $details->getLatitude();
// 37.386
echo $details->getLongitude();
// -122.0838
var_dump($details->toArray());
// Array
// (
// [city] => Mountain View
// [region] => California
// [country] => United States
// [countryCode] => US
// [latitude] => 37.386
// [longitude] => -122.0838
//)