itech-ro / geolocation
Geolocation services for Laravel 5.x
Installs: 26
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/itech-ro/geolocation
Requires
- php: >=5.6
- guzzlehttp/guzzle: ^6.3
This package is not auto-updated.
Last update: 2025-12-21 11:12:50 UTC
README
This package provides geolocation information including country, city, latitude and longitude based on request IP. There are a few available providers: Extreme IP Lookup, Free GeoIP, Geobytes and Geoplugin.
Instalation
Install the package using composer:
composer require itech-ro/geolocation
Edit app/config.php and add this line to providers array:
'providers' => [
...
Roitech\Geolocation\GeolocationServiceProvider::class,
...
];
Create a configuration file config/geolocation.php with the content:
<?php
return [
'provider' => 'geoplugin',
];
How to use it
Once you set the preferred provider in config/geolocation.php (possible values: geobytes, freegeoip, extremeiplookup, geoplugin) the geolocation details can be accessed using the Geolocation facade:
$coordinates = Geolocation::getCoordinates(); //returns an array [ 'lat' => LATITUDE, 'long' => LONGITUDE ]
$city = Geolocation::getCity();
$country = Geolocation::getCountry();