cyber-duck / laravel-maxmind-geolocate
Laravel Package to utilise MaxMind GeoLite2 Database for IP based GeoLocation
v1.0.2
2023-07-26 10:55 UTC
Requires
- php: ^8.1
- geoip2/geoip2: ^2.13
- guzzlehttp/guzzle: ^7.5
- illuminate/console: ^8.0|^9.0|^10.0
- illuminate/support: ^8.67|^9.0|^10.0
Requires (Dev)
- orchestra/testbench: ^8.5
This package is auto-updated.
Last update: 2024-12-08 11:28:00 UTC
README
This package utilises the MaxMind GeoLite databases to allow GeoLocation of an IP Address.
Console Commands
php artisan geolocation:update
Downloads a recent archive of the database from MaxMind, validates the hash, and stores on a remote disk (e.g S3) as specified in configuration.
php artisan geolocation:fetch
Fetches, extracts, and moves to application storage, the archive previously stored on a remove disk (e.g S3)
Usage
Once a database has been downloaded and extracted to the app local storage directory, to geolocate an IP address, use the provided facade, as such:
use CyberDuck\GeoLocate\Facades\GeoLocate; $result = GeoLocate::country('1.2.3.4'); // $result is an instance of \GeoIp2\Record\Country $result->isoCode // == 'GB' for example.