barstec / ip-api
Package for handling the ipapi.is API in Laravel
v1.1.1
2024-09-30 15:33 UTC
Requires
- guzzlehttp/guzzle: ^7.9
- illuminate/support: >=10.0
README
A package for handling the ipapi.is API in Laravel. You will need an API key from ipapi.is.
Support
If this package is helpful to you, you can support my work on Ko-fi.
Installation
- Install composer package using command:
composer require barstec/ip-api
- Publish configuration files to your project
php artisan vendor:publish --provider="Barstec\IpApi\IpApiServiceProvider"
Setup
First, add an environment variable with your API key to the .env
file:
IP_API_KEY=your_api_key
Usage
Create an IpApi object and call the get method. You can pass an IP address as a parameter. If left empty, the IP from the current request will be used. The result will be an stdClass.
Example of geting city location:
$ipApi = new IpApi; $result = $ipApi->get("8.8.8.8"); $result->location->city;
Author
License
This package is distributed under the MIT license