PHPackages                             seeley/ip2location - 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. seeley/ip2location

ActiveLibrary[API Development](/categories/api)

seeley/ip2location
==================

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

1.0(5y ago)0520MITPHP

Since Jul 27Pushed 5y ago1 watchersCompare

[ Source](https://github.com/Seeley-wang/ip2location)[ Packagist](https://packagist.org/packages/seeley/ip2location)[ Docs](http://www.ip2location.com)[ RSS](/packages/seeley-ip2location/feed)WikiDiscussions master Synced 4d ago

READMEChangelogDependenciesVersions (2)Used By (0)

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, 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, and usage type 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.

INSTALLATION
------------

[](#installation)

To install this module, unzip the package and copy the following files to your web folder.

- IP2Location.php
- example.php
- databases/IP2LOCATION-LITE-DB1.BIN

To test this installation, please browse example.php using web browser.

USAGE
-----

[](#usage)

You can check the **example.php** file to learn more about usage.

### Database Class

[](#database-class)

Below is the description of the functions available in the **Database** class.

Function NameDescriptionConstructorExpect 2 input parameters:1. Full path of IP2Location BIN data file.
2. File Open Mode
    - SHARED\_MEMORY
    - MEMORY\_CACHE
    - FILE\_IO

For SHARED\_MEMORY and MEMORY\_CACHE, it will require your server to have sufficient memory to hold the BIN data, otherwise it will raise the errors during the object initialization.getDateReturn the database's compilation date as a string of the form 'YYYY-MM-DD'getTypeReturn the database's type, 1 to 24 respectively for DB1 to DB24. Please visit  for details.getModuleVersionReturn the version of modulegetDatabaseVersionReturn the version of databaselookupReturn the IP information in array. Below is the information returned:- ipNumber
- ipVersion
- ipAddress
- countryCode
- countryName
- regionName
- cityName
- latitude
- longitude
- areaCode
- iddCode
- weatherStationCode
- weatherStationName
- mcc
- mnc
- mobileCarrierName
- usageType
- elevation
- netSpeed
- timeZone
- zipCode
- domainName
- isp

You can visit [IP2Location](https://www.ip2location.com/databases/db24-ip-country-region-city-latitude-longitude-zipcode-timezone-isp-domain-netspeed-areacode-weather-mobile-elevation-usagetype) for the description of each field. Note: although the above names are not exactly matched with the names given in this link, but they are self-described.getCidrReturn an array of the sub-network of an IP address.### WebService Class

[](#webservice-class)

Below is the description of the functions available in the **WebService** class.

Function NameDescriptionConstructorExpect 3 input parameters:1. IP2Location API Key.
2. Package (WS1 - WS24)
3. Use HTTPS or HTTP

lookupReturn the IP information in array.- country\_code
- country\_name
- region\_name
- city\_name
- latitude
- longitude
- zip\_code
- time\_zone
- isp
- domain
- net\_speed
- idd\_code
- area\_code
- weather\_station\_code
- weather\_station\_name
- mcc
- mnc
- mobile\_brand
- elevation
- usage\_type
- continent
    - name
    - code
    - hemisphere
    - translations
- country
    - name
    - alpha3\_code
    - numeric\_code
    - demonym
    - flag
    - capital
    - total\_area
    - population
    - currency
        - code
        - name
        - symbol
    - language
        - code
        - name
    - idd\_code
    - tld
    - translations
- region
    - name
    - code
    - translations
- city
    - name
    - translations
- geotargeting
    - metro
- country\_groupings
- time\_zone\_info
    - olson
    - current\_time
    - gmt\_offset
    - is\_dst

getCreditReturn remaining credit of the web service account.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.

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)

COPYRIGHT AND LICENCE
---------------------

[](#copyright-and-licence)

Copyright (C) 2005-2020 by IP2Location.com

License under MIT

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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

2119d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/eb31afc03645c8a3e9d90cf9e292a575588d737690e41139298bbb6b3d203c63?d=identicon)[Seeley](/maintainers/Seeley)

---

Top Contributors

[![alexyuetmout](https://avatars.githubusercontent.com/u/25193846?v=4)](https://github.com/alexyuetmout "alexyuetmout (2 commits)")

---

Tags

geolocationip2locationip2locationlite

### Embed Badge

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

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

###  Alternatives

[geoip2/geoip2

MaxMind GeoIP2 PHP API

2.5k85.4M294](/packages/geoip2-geoip2)[ip2location/ip2location-php

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

2133.9M33](/packages/ip2location-ip2location-php)[igaster/laravel_cities

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

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

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

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

Wrapper for Nominatim API

51396.0k2](/packages/maxh-php-nominatim)

PHPackages © 2026

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