PHPackages                             tgkw-adc/ip2location-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. tgkw-adc/ip2location-php

ActiveLibrary[API Development](/categories/api)

tgkw-adc/ip2location-php
========================

\[Official Release\] IP2Location PHP API to get location info from IPv4 and IPv6 address.

1.0.3(7mo ago)02101MITPHPPHP &gt;=7.2

Since Nov 26Pushed 7mo agoCompare

[ Source](https://github.com/yangzai929/tgkw-adc-ip2location-php)[ Packagist](https://packagist.org/packages/tgkw-adc/ip2location-php)[ Docs](https://www.ip2location.com)[ RSS](/packages/tgkw-adc-ip2location-php/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (1)Versions (2)Used By (1)

IP2Location (PHP Module)
========================

[](#ip2location-php-module)

[![Latest Stable Version](https://camo.githubusercontent.com/85c76ed0e3f9808d913a19b34a99a2ec901c8b7bb96544bcd8366f7ac9ca9784/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6970326c6f636174696f6e2f6970326c6f636174696f6e2d7068702e737667)](https://packagist.org/packages/ip2location/ip2location-php)[![Total Downloads](https://camo.githubusercontent.com/4a8dd61ea8aab1c69a4dc57b2648759b10d979607104202a76095e7b755935cf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6970326c6f636174696f6e2f6970326c6f636174696f6e2d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ip2location/ip2location-php)

*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:

1. select the geographically closest mirror
2. analyze your web server logs to determine the countries of your visitors
3. credit card fraud detection
4. software export controls
5. display native language and currency
6. prevent password sharing and abuse of service
7. geotargeting in advertisement

Free IP2Location LITE and commerical databases are available for download.

- LITE database is available at  (Free with limited accuracy)
- Commercial database is availabe at  (Comprehensive with high accuracy)

Monthly update is available for both IP2Location LITE and commercial database.

KEY FEATURES
------------

[](#key-features)

1. **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.
2. **Extensible.** If you require different granularity of IP information, you can visit [IP2Location.com](https://www.ip2location.com/databases) to download the relevant BIN file, and the information will made ready for you.
3. **Comprehensive Information.** There are more than 13 types of information that you can retrieve from an IP address. Please visit [IP2Location.com](https://www.ip2location.com/databases) for details.

Developer Documentation
=======================

[](#developer-documentation)

To learn more about installation, usage, and code examples, please visit the developer documentation at .

DEPENDENCIES
------------

[](#dependencies)

This library requires IP2Location BIN data file to function. You may download the BIN data file at

- IP2Location LITE BIN Data (Free):
- IP2Location Commercial BIN Data (Comprehensive):

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](https://www.ip2location.com/web-service/ip2location) to lookup by IP2Location API.

BIN DOWNLOADER SCRIPT
---------------------

[](#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.

ParametersDescriptiontokenDownload token. You can get your token at your [IP2Location Account Area](https://www.ip2location.com/account) at the Download page.fileDatabase package. (DB1BIN...DB26BIN, DB1BINIPV6...DB26BINIPV6, DB1LITEBIN...DB11LITEBIN or DB1LITEBINIPV6...DB11LITEBINIPV6) You may login to your [IP2Location Account Area](https://www.ip2location.com/account) and get the package code (or download code) at the Download page.yAuto replace the current BIN file without acknowledgement.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
--------------------

[](#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
-----------------------

[](#other-framework-library)

Below are the list of other framework library that you can install and use right away.

- [IP2Location Laravel](https://github.com/ip2location/ip2location-laravel)
- [IP2Location CakePHP](https://github.com/ip2location/ip2location-cakephp)
- [IP2Location CodeIgniter](https://github.com/ip2location/codeigniter-ip2location)
- [IP2Location Yii](https://github.com/ip2location/ip2location-yii)
- [Symfony Framework](https://blog.ip2location.com/knowledge-base/geolocation-lookup-using-symfony-4-and-ip2location-bin-database/). Tutorial on the Symfony implementation.

COPYRIGHT AND LICENSE
---------------------

[](#copyright-and-license)

Copyright (C) 2005-2025 by IP2Location.com

License under MIT

// 初始化数据库连接（FILE\_IO 模式，适合小数据库；MEMORY\_CACHE 模式更高效，需更多内存） $db = new Database(); $record = $db-&gt;lookup($ip, Database::ALL); // 解析所有信息

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance64

Regular maintenance activity

Popularity15

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity30

Early-stage or recently created project

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

220d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/32031389?v=4)[dennywo](/maintainers/yangzai929)[@yangzai929](https://github.com/yangzai929)

---

Tags

geolocationzip codetime zoneip2locationip2locationlitearea codeispmccip geolocationmncusage type

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tgkw-adc-ip2location-php/health.svg)

```
[![Health](https://phpackages.com/badges/tgkw-adc-ip2location-php/health.svg)](https://phpackages.com/packages/tgkw-adc-ip2location-php)
```

###  Alternatives

[ip2location/ip2location-php

\[Official Release\] IP2Location PHP API to get location info from IPv4 and IPv6 address.

2244.2M37](/packages/ip2location-ip2location-php)[geoip2/geoip2

MaxMind GeoIP PHP API

2.5k92.0M361](/packages/geoip2-geoip2)[igaster/laravel_cities

Seed all countries/cities from geonames.org database. Searchable DB tree, ready to use API &amp; a bonus vue.js component!

18394.5k1](/packages/igaster-laravel-cities)[jeroendesloovere/geolocation-php-api

This Geolocation PHP class connects to Google Maps API to find latitude/longitude or address.

79325.4k4](/packages/jeroendesloovere-geolocation-php-api)[maxh/php-nominatim

Wrapper for Nominatim API

51411.1k2](/packages/maxh-php-nominatim)[ipgeolocation/ipgeolocation-php-sdk

Official PHP SDK for the IPGeolocation.io IP Location API with single and bulk lookup support.

414.8k](/packages/ipgeolocation-ipgeolocation-php-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
