PHP code example of victorybiz / geoip-location

1. Go to this page and download the library: Download victorybiz/geoip-location library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

victorybiz / geoip-location example snippets


'providers' => [

    Victorybiz\GeoIPLocation\GeoIPLocationServiceProvider::class,

]

'aliases' => [

	'GeoIPLocation' => Victorybiz\GeoIPLocation\Facades\GeoIPLocationFacade::class,

]

use GeoIPLocation;

echo GeoIPLocation::getIP(); // Return client IP

    

    use Victorybiz\GeoIPLocation\GeoIPLocation;

    $geoip = new GeoIPLocation(); 

    // OR

    $geoip = new GeoIPLocation([
        'ip' => null, // Set IP.  Default is NULL, will be auto set by the package
        'baseCurrency' => 'USD', // Set base currency for exchange rate. Default is USD
    ]);

    $geoip = new \Victorybiz\GeoIPLocation\GeoIPLocation();

    // OR

    $geoip = new \Victorybiz\GeoIPLocation\GeoIPLocation([
        'ip' => null, // Set IP.  Default is NULL, will be auto set by the package
        'baseCurrency' => 'USD', // Set base currency for exchange rate. Default is USD
    ]);

    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)