ip2location / ip2location-php
[Official Release] IP2Location PHP API to get location info from IPv4 and IPv6 address.
Installs: 2 723 166
Dependents: 28
Suggesters: 0
Security: 0
Stars: 197
Watchers: 12
Forks: 69
Open Issues: 0
Requires
- php: >=7.2
- ext-bcmath: *
- ext-curl: *
- ext-json: *
Requires (Dev)
- phpunit/phpunit: ^9.5
README
This is the official release maintained by IP2Location.com
This PHP module provides fast lookup of country, region, district, city, latitude, longitude, ZIP code, time zone, ISP, domain name, connection speed, IDD code, area code, weather station code, weather station name, MNC, MCC, mobile brand, elevation, usage type, address type, IAB category and ASN from IP address by using IP2Location database. This module uses a file based database available at IP2Location.com.
This module can be used in many types of projects such as:
- select the geographically closest mirror
- analyze your web server logs to determine the countries of your visitors
- credit card fraud detection
- software export controls
- display native language and currency
- prevent password sharing and abuse of service
- geotargeting in advertisement
Free IP2Location LITE and commerical databases are available for download.
- LITE database is available at https://lite.ip2location.com (Free with limited accuracy)
- Commercial database is availabe at https://www.ip2location.com (Comprehensive with high accuracy)
Monthly update is available for both IP2Location LITE and commercial database.
KEY FEATURES
- Support both IPv4 and IPv6 with ease. If you would like to enable IPv6 support, you just need to replace your BIN file with IPv6 version. That's it, and no code modification needed.
- Extensible. If you require different granularity of IP information, you can visit IP2Location.com to download the relevant BIN file, and the information will made ready for you.
- Comprehensive Information. There are more than 13 types of information that you can retrieve from an IP address. Please visit IP2Location.com for details.
Developer Documentation
To learn more about installation, usage, and code examples, please visit the developer documentation at https://ip2location-php.readthedocs.io/en/latest/index.html.
DEPENDENCIES
This library requires IP2Location BIN data file to function. You may download the BIN data file at
- IP2Location LITE BIN Data (Free): https://lite.ip2location.com
- IP2Location Commercial BIN Data (Comprehensive): https://www.ip2location.com
An outdated BIN database was provided in the databases folder for your testing. You are recommended to visit the above links to download the latest BIN database.
You can also sign up for IP2Location Web Service to lookup by IP2Location API.
BIN DOWNLOADER SCRIPT
php ip2location_bin_download.php --token DOWNLOAD_TOKEN --file DATABASE_CODE -y
The command above will download the DATABASE_CODE BIN file and unzip the file into data folder.
You can set the DOWNLOAD_TOKEN and DATABASE_CODE with values in the .env file (same path as ip2location_bin_download.php) and run the command php ip2location_bin_download.php
for the download.
IPv4 BIN vs IPv6 BIN
- Use the IPv4 BIN file if you just need to query IPv4 addresses.
- Use the IPv6 BIN file if you need to query BOTH IPv4 and IPv6 addresses.
OTHER FRAMEWORK LIBRARY
Below are the list of other framework library that you can install and use right away.
- IP2Location Laravel
- IP2Location CakePHP
- IP2Location CodeIgniter
- IP2Location Yii
- Symfony Framework. Tutorial on the Symfony implementation.
COPYRIGHT AND LICENSE
Copyright (C) 2005-2024 by IP2Location.com
License under MIT