Package Data | |
---|---|
Maintainer Username: | victorybiz |
Maintainer Contact: | lavictorybiz@gmail.com (Victory Osayi) |
Package Create Date: | 2017-07-31 |
Package Last Update: | 2021-12-29 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-30 15:05:08 |
Package Statistics | |
---|---|
Total Downloads: | 126,824 |
Monthly Downloads: | 1,653 |
Daily Downloads: | 38 |
Total Stars: | 22 |
Total Watchers: | 1 |
Total Forks: | 4 |
Total Open Issues: | 1 |
Get the geographical location of website visitors based on their IP addresses. Support Laravel 5 and PHP (Non-Laravel) Project.
Install using composer, from the command line run:
$ composer require victorybiz/geoip-location
Alternatively, you can add "victorybiz/geoip-location": "~1.0"
to your composer.json file's require
section and
then run $ composer update
.
Once installed you need to register the service provider with the application. Open up config/app.php
and locate the providers
key.
'providers' => [
Victorybiz\GeoIPLocation\GeoIPLocationServiceProvider::class,
]
Require the autoload file in your php script.
require_once 'path/to/vendor/autoload.php';
localhost IP 127.0.0.1
and ::1
will return 169.159.82.111
to assert a valid geo response.
use Victorybiz\GeoIPLocation\GeoIPLocation;
$geoip = new GeoIPLocation();
Alternatively
$geoip = new \Victorybiz\GeoIPLocation\GeoIPLocation();
You're good to go, explore the package
echo $geoip->getIP(); // Return client IP
echo $geoip->setIP('0.0.0.0'); // Set an IP to get its geographical location
echo $geoip->getCity(); // Return client IP City (null if none)
echo $geoip->getRegion(); // Return client IP Region (null if none)
echo $geoip->getRegionCode(); // Return client IP Region Code (null if none)
echo $geoip->getCountry(); // Return client IP Country
echo $geoip->getCountryCode(); // Return client IP Country Code
echo $geoip->getContinent(); // Return client IP Continent
echo $geoip->getContinentCode(); // Return client IP Continent Code
echo $geoip->getPostalCode(); // Return client IP Postal Code (null if none)
echo $geoip->getLatitude(); // Return client IP Latitude (null if none)
echo $geoip->getLongitude(); // Return client IP Longitude (null if none)
echo $geoip->getCurrencyCode(); // Return client IP Country Currency Code (null if none)
echo $geoip->getCurrencySymbol(); // Return client IP Country Currency Symbol (null if none)
echo $geoip->getCurrencyExchangeRate(); // Return client IP Country Currency Exchange Rate against NGN (null if none)
echo $geoip->getLocation(); // Return client IP Location string (city, region, country)
Kindly make use of the issue tracker for bug reports, feature request, additional web service request and security issues.