PHP code example of bkhim / laravel-geolocation

1. Go to this page and download the library: Download bkhim/laravel-geolocation 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/ */

    

bkhim / laravel-geolocation example snippets


$details = Geolocation::lookup();
echo $details->getCity();          // "Mountain View"
echo $details->getTimezone();      // "America/Los_Angeles"
echo $details->getCurrencyCode();  // "USD"

if ($details->isProxy() || $details->isTor()) {
    return redirect()->route('mfa.challenge');
}

// Or get a full risk assessment
$risk = $user->getRiskScore($request->ip());
// ['score' => 45, 'is_high_risk' => false, 'triggers' => [...]]

// That's it.
$location = Geolocation::lookup('8.8.8.8');
echo $location->getCountry(); // "United States"
bash
composer vendor:publish --provider="Bkhim\Geolocation\GeolocationServiceProvider" --tag=geolocation-config

# For security features (login tracking, IP blocking):
php artisan vendor:publish --tag=geolocation-migrations
php artisan migrate