Skip to content

Laravel service provider to retrieve a users location from their IP address using freegeoip.app service.

License

Notifications You must be signed in to change notification settings

Psonrie/geolocation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Travis CI Scrutinizer Code Quality Latest Stable Version Total Downloads License

Geo Location

Laravel service provider to retrieve a users location from their IP address using freegeoip.app or geolocation-db service.

Requirements

  • Laravel >= 5.5
  • PHP 7.0 or greater
  • cURL extension enabled

Installation

Via Composer

composer require psonrie/geolocation

Note: If you're using Laravel 5.5 or above, you can skip the registration of the service provider, as it is registered automatically.

Add the service provider in config/app.php:

Psonrie\GeoLocation\GeoLocationServiceProvider::class,

Publish the config file:

php artisan vendor:publish --provider="Psonrie\GeoLocation\GeoLocationServiceProvider"

Usage

Retrieving a users location

$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
}

Contribute

Contributions are welcome! Send a pull request to the main repository or report any issues you find on the issue tracker.

License

The MIT License (MIT). Please see LICENSE for more information.

About

Laravel service provider to retrieve a users location from their IP address using freegeoip.app service.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages