PHP code example of laravelcm / abstract-ip-geolocation

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

    

laravelcm / abstract-ip-geolocation example snippets


protected $middleware = [
    ...
    \Laravelcm\AbstractIpGeolocation\Middleware\AbstractIpGeolocation::class,
];

Route::get('/', function () {
    $geolocation = session()->get('abstract-ip-geolocation')
    $location = "The IP address " . $geolocation->ipAddress;
    return view('index', ['location' => $location]);
});

/*
|--------------------------------------------------------------------------
| Geolocation Fields
|--------------------------------------------------------------------------
| You can actapi.com/ip-geolocation#request-parameters
*/

'fields' => null,

$geolocation = session()->get('abstract-ip-geolocation');

$geolocation->country // return "France"
$currency = $geolocation->currency // instance of \Laravelcm\AbstractIpGeolocation\DataObject\Currency