PHP code example of skywalker-labs / location

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

    

skywalker-labs / location example snippets


use Skywalker\Location\Facades\Location;

// Auto-detect visitor location
$position = Location::get(); 

echo $position->countryName; // e.g., "United States"
echo $position->cityName;    // e.g., "New York"

if ($position->is_spoofed) {
    // Distance > 500km between IP and GPS detected
    abort(403, 'Location Verification Failed');
}

Route::middleware(['location.rate-limit'])->group(function () {
    Route::post('/login', [LoginController::class, 'store']);
});
bash
php artisan vendor:publish --provider="Skywalker\Location\LocationServiceProvider"
php artisan migrate