PHP code example of psonrie / geolocation

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

    

psonrie / geolocation example snippets


Psonrie\GeoLocation\GeoLocationServiceProvider::class,

$geoLocation = new GeoLocation();

$response = $geoLocation->get('46.24.247.56');

// Returns instance of Psonrie\GeoLocation\Response

Psonrie\GeoLocation\Response {
  ip: "46.24.247.56"
  countryCode: "ES"
  countryName: "Spain"
  regionCode: "CT"
  regionName: "Catalonia"
  cityName: "Barcelona"
  zipCode: "08004"
  timeZone: "Europe/Madrid"
  latitude: "41.3891"
  longitude: "2.1611"
  metroCode: 0
}
bash
php artisan vendor:publish --provider="Psonrie\GeoLocation\GeoLocationServiceProvider"