PHPackages                             ip2location/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. ip2location/ip2location-php

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

ip2location/ip2location-php
===========================

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

9.8.1(4mo ago)2133.9M—6.2%6820MITPHPPHP &gt;=7.2CI passing

Since Sep 18Pushed 4mo ago12 watchersCompare

[ Source](https://github.com/chrislim2888/IP2Location-PHP-Module)[ Packagist](https://packagist.org/packages/ip2location/ip2location-php)[ Docs](https://www.ip2location.com)[ RSS](/packages/ip2location-ip2location-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (39)Used By (20)

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

###  Health Score

64

—

FairBetter than 99% of packages

Maintenance75

Regular maintenance activity

Popularity63

Solid adoption and visibility

Community36

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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

Every ~111 days

Recently: every ~192 days

Total

38

Last Release

148d ago

Major Versions

7.2.5 → 8.0.02016-07-05

8.3.0 → 9.0.02021-03-04

### Community

Maintainers

![](https://www.gravatar.com/avatar/49d93e7c08bc68d06c6c7c508d36c3c1c7a8c2dc8038386f2e8ae5e91e130362?d=identicon)[chrislim2888](/maintainers/chrislim2888)

---

Top Contributors

[![ip2location-com](https://avatars.githubusercontent.com/u/6367210?v=4)](https://github.com/ip2location-com "ip2location-com (59 commits)")[![chrislim2888](https://avatars.githubusercontent.com/u/3418232?v=4)](https://github.com/chrislim2888 "chrislim2888 (57 commits)")[![summerKK](https://avatars.githubusercontent.com/u/19187969?v=4)](https://github.com/summerKK "summerKK (13 commits)")[![gbaquedano](https://avatars.githubusercontent.com/u/11883755?v=4)](https://github.com/gbaquedano "gbaquedano (1 commits)")[![gjuric](https://avatars.githubusercontent.com/u/223015?v=4)](https://github.com/gjuric "gjuric (1 commits)")[![onesvat](https://avatars.githubusercontent.com/u/2061096?v=4)](https://github.com/onesvat "onesvat (1 commits)")[![zygimantas-skinkys](https://avatars.githubusercontent.com/u/17708625?v=4)](https://github.com/zygimantas-skinkys "zygimantas-skinkys (1 commits)")

---

Tags

area-codecitycountrydomainelevationgeolocationip-addressip-locationip-lookupip2locationiplocationipv4ipv6ispmobile-infophpregiontimezoneweather-stationzip-codegeolocationzip codetime zoneip2locationip2locationlitearea codeispmccip geolocationmncusage type

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[torann/geoip

Support for multiple Geographical Location services.

2.2k14.2M76](/packages/torann-geoip)[ip2location/ip2location-laravel

Lookup for visitor's IP information, such as country, region, city, coordinates, zip code, time zone, ISP, domain name, connection type, area code, weather, MCC, MNC, mobile brand name, elevation and usage type.

83516.9k1](/packages/ip2location-ip2location-laravel)[pulkitjalan/ip-geolocation

IP Geolocation Wrapper with Laravel Support

89164.9k1](/packages/pulkitjalan-ip-geolocation)[anthonymartin/geo-location

Powerful GeoCoding library: Retrieve bounding box coordinates, distances between geopoints, point in polygon, get longitude and latitude from addresses and more with GeoLocation for PHP

196949.5k5](/packages/anthonymartin-geo-location)[atchondjo/geoip2country

A lightweight but powerful IP address lookup database solution to determine visitors country

344.1k](/packages/atchondjo-geoip2country)[spatie/google-time-zone

Get time zones for coordinates

110660.6k1](/packages/spatie-google-time-zone)

PHPackages © 2026

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