PHP code example of interaction-design-foundation / laravel-geoip
1. Go to this page and download the library: Download interaction-design-foundation/laravel-geoip 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/ */
interaction-design-foundation / laravel-geoip example snippets
geoip()->getLocation('27.974.399.65'); // Get the location from the provided IP.
geoip()->getClientIP(); // Will return the user IP address.
\InteractionDesignFoundation\GeoIP\Location {[
'ip' => '1.1.1.1',
'iso_code' => 'US',
'country' => 'United States',
'city' => 'New Haven',
'state' => 'CT',
'state_name' => 'Connecticut',
'postal_code' => '06510',
'lat' => 41.28,
'lon' => -72.88,
'timezone' => 'America/New_York',
'continent' => 'NA',
'currency' => 'USD',
'default' => false,
]}
$location = geoip()->getLocation();
$city = $location->city;
// The same as:
$city = $location['city'];
sh
php artisan vendor:publish --provider="InteractionDesignFoundation\GeoIP\GeoIPServiceProvider" --tag=config
sh
php artisan geoip:update
sh
php artisan geoip:clear