Geo location service package
The package is a wrapper for several geolocation services at once. The main task of the package is to determine the user's location by IP. Due to the possibility of using several providers at once, the free limit of each provider is summed up.
Install
Via Composer
$ composer require codeblog.pro/geo-location
Usage
$geoLocationService = new \CodeblogPro\GeoLocation\Application\Services\GeoLocationService();
$location = $geoLocationService->getLocationByIpAndLanguageResultCode('8.8.8.8', 'EN');
var_dump($location);
$locationArray = $geoLocationService->getLocationArrayByIpAndLanguageResultCode('8.8.8.8', 'RU');
var_dump($locationArray);
$currentIpResolver = new \CodeblogPro\GeoLocation\Application\Services\CurrentIpResolver();
$currentIp = $geoLocationService->getCurrentIpByIpResolver($currentIpResolver)->getValue();
var_dump($currentIp);
$locationByIpResolverAndLanguageResultCode = $geoLocationService->getLocationByIpResolverAndLanguageResultCode(
$currentIpResolver,
'RU'
);
var_dump($locationByIpResolverAndLanguageResultCode);
Testing
$ composer test
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email panov@codeblog.pro instead of using the issue tracker.
Credits
License
The Apache License License. Please see License File for more information.