soltivo / location
A simple library to detect location of an ip address.
1.0.0
2020-05-29 20:01 UTC
Requires
- guzzlehttp/guzzle: ~6.0
- php-parallel-lint/php-console-color: ^0.3.0
This package is auto-updated.
Last update: 2025-03-18 20:44:53 UTC
README
With the help of this simple library, you can get Country, State, City, and many other pieces of information about your users.
This library uses the ip-api.com to retrieve IP location data.
Installation
composer require soltivo/location
Usage
$options = [ "ip" => "127.0.0.1", "lang" => "en", "fields" => [ "isp", "org", "as", ] ]; $location = new \Soltivo\Location\Location($options); $countryaa2 = $location->countryCode; $state = $location->stateName; $city = $location->city;
Options
$options = [ "ip" => "", "fields" => [], "lang" => "", "test" => false ];
The works component can be appended to other resources.
parameter | type | description | required | see |
---|---|---|---|---|
ip | string | IP address of the user. | yes | |
fields | array | Fields to retrieve. | no | Fields List |
lang | string | Language to retrieve data | no | Localization |
test | boolean | Set true to use for testing connection issues | no |
Default values
$testing = false; $lang = "en"; $fields = [ "country", "countryCode", "region", "regionName", "city", "zip", "proxy", "currency", "timezone", "continent", "continentCode", "district" ];
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
License
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.