Get geolocation information based on the IP address of the user. This package uses Geo IP Api to get geo information. Both IPv4 and IPv6 are supported.
Geo IP Api allows only 150 requests per minute. If you exceed this limit your Ip will be blocked by Geo IP Api
You can install the package using composer
composer require yasir-dev/ip-geolocation
// use the package
use ipGeolocation\GeoIPLocation;
//get the ip address
$ipAddress = (new GeoIPLocation())->getIpAddress();
// get the location object
$location = (new GeoIPLocation())->getGeoLocation();
//check the status for success
$location->getStatus();
//get the required information
$location->getCountry();
$location->getRegionName();
$location->getRegionCode();
$location->getPostalCode();
$location->getTimezone();
$location->getCurrencyIso();
$location->getCity();
$location->getLongitude();
$location->getLatitude();
//handling error (status fail)
if (!$location->getStatus()) {
//get error message
$location->getMessage();
}
- Determine user's location.
- Determine user's currency/language.
- Customise your website based on user's location.
Please feel free to open new issues, pull requests, fork or spread the package
MIT © Yasir Khurshid