testingmic / geoip2country
Get the current visitor IP Address and determine the country, city, latitude, longitude, and ISP
Installs: 34
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/testingmic/geoip2country
This package is auto-updated.
Last update: 2025-11-15 12:22:31 UTC
README
An IP address helps you identify visitors geographical location.
A PHP IP Address Geolocation library to help you identify visitors geographical location.
Requirements
- pdo_sqlite (runtime deps)
- php_curl (for update only)
Installation And Initialisation :
These instructions will get you a copy of the project up and running on your local machine. there are two options:
- Using Composer installer(Recommended) by typing the following command:
composer require testingmic/geoip2country
Usage: (using Composer autoloader)
require __DIR__ . '/vendor/autoload.php'; try { $IpAddressGeo = new testingmic\IpAddressGeoLocation(); } catch (\Throwable $th) { trigger_error($th->getMessage(), E_USER_ERROR); }
Getting Country code from given IP address:
$ipAddress_1='37.140.250.97'; echo '<pre>'; print_r($IpAddressGeo->resolve($ipAddress_1)); Array ( [start] => 629996032 [end] => 629996288 [country_code] => UA [country_name] => United States [continent_code] => NA [city] => Alexandria [latitude] => 38.8031 [longitude] => -77.0388 )
Getting current visitor Country code (auto detect his IP address):
echo '<pre>'; print_r($IpAddressGeo->resolve()); /** resolve() method called without any argument */