Laravel GeoIP is a simple package to retrieve geographical location data from an IP address using the ip-api.com API.
Install via Composer:
composer require manka/geo-ip
If you're using Laravel <5.5, you must manually register the service provider in config/app.php:
```php
'providers' => [
// ...
manka\GeoIP\GeoIPServiceProvider::class,
],
⚙️ Configuration Publish the configuration file (optional):
php artisan vendor:publish --tag=configThis will create a config/geoip.php file you can modify.
🚀 Usage Use the package like this:
use GeoIP;
$location = GeoIP::lookup(); // Uses current request IP
$customLocation = GeoIP::lookup('8.8.8.8'); // Pass a specific IP
dd($location);Sample Output
{
"status": "success",
"country": "United States",
"regionName": "California",
"city": "Mountain View",
"zip": "94043",
"lat": 37.422,
"lon": -122.084,
"timezone": "America/Los_Angeles",
"isp": "Google LLC",
"query": "8.8.8.8"
}
✅ Features
- Get geo location from IP address
- Automatically detect current IP
- Simple API, no setup required
- Uses public API (ip-api.com)
Developed with ❤️ by Pawan Manka