Abstract’s IP Geolocation API is a fast, lightweight, modern, and RESTful JSON API for determining the location and other details of IP addresses from over 190 countries.
The free plan is limited to 1,000 requests per month. To enable all the data fields and additional request volumes see https://www.abstractapi.com/api/ip-geolocation-api#pricing.
The package works with PHP 8 and is available using Composer.
composer require laravelcm/abstract-ip-geolocation
Open your application's \app\Http\Kernel.php
file and add the following to the Kernel::middleware
property:
protected $middleware = [
...
\Laravelcm\AbstractIpGeolocation\Middleware\AbstractIpGeolocation::class,
];
Route::get('/', function () {
$location = "The IP address " . request()->get('abstract-ip-geolocation')['ip_address'];
return view('index', ['location' => $location]);
});
Will return the following string to the index
view:
"The IP address 127.0.0.1."
wip..
wip..
This package is open-sourced software licensed under the MIT license.