graymatterlabs / geoip
GeoIp capable of supporting any Ip to geolocation service
v3.0
2023-06-18 21:54 UTC
Requires
- php: ^8.2
- psr/simple-cache: ^3.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.9
- geoip2/geoip2: ~2.1
- phpstan/phpstan: ^1.8
- phpunit/phpunit: ^9.5
Suggests
- geoip2/geoip2: Required to use the MaxMind service (~2.1)
- graymatterlabs/simple-cache: Provides implementations of psr/simple-cache (~1.1)
This package is auto-updated.
Last update: 2024-10-23 20:41:54 UTC
README
This package provides an opinionated framework for resolving geolocations from IP addresses.
Installation
You can install the package via composer:
composer require graymatterlabs/geoip:^3.0
Usage
use GrayMatterLabs\GeoIp\GeoIp; // $locator = new GrayMatterLabs\GeoIp\Locators\Cached($locator, $cache); $geoip = new GeoIp($locator); $location = $geoip->locate($ip); $location->getCountryCode(); // 'US' if ($location->isDefault()) { // }
Testing
composer test
Changelog
Please see the Release Notes for more information on what has changed recently.
Credits
License
The MIT License (MIT). Please see License File for more information.