PHPackages                             ip2location/ip2location-yii - 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-yii

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

ip2location/ip2location-yii
===========================

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.

1.0.1(2y ago)71.3k2MITPHPPHP &gt;=5.4.0

Since Sep 22Pushed 4mo ago2 watchersCompare

[ Source](https://github.com/ip2location/ip2location-yii)[ Packagist](https://packagist.org/packages/ip2location/ip2location-yii)[ Docs](https://github.com/ip2location/ip2location-yii)[ RSS](/packages/ip2location-ip2location-yii/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

IP2Location Yii extension
=========================

[](#ip2location-yii-extension)

IP2Location Yii extension enables the user to find the country, region, city, coordinates, zip code, time zone, ISP, domain name, connection type, area code, weather, MCC, MNC, mobile brand name, elevation, usage type, IP address type and IAB advertising category from IP address using IP2Location database. It has been optimized for speed and memory utilization. Developers can use the API to query all IP2Location BIN databases or web service for applications written using Yii

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

[](#installation)

For Yii2

1. Run the command: `composer require ip2location/ip2location-yii` to download the extension into the Yii2 framework.
2. Download latest IP2Location BIN database
    - IP2Location free LITE database at
    - IP2Location commercial database at
3. Unzip and copy the BIN file into the Yii2 framework.

**Note:** The BIN database refers to the binary file ended with .BIN extension, but not the CSV format. Please select the right package for download.

USAGE
-----

[](#usage)

```
use IP2LocationYii\IP2Location_Yii;

// (required) Define IP2Location database path.
define('IP2LOCATION_DATABASE', '/path/to/ip2location/database');

// (required) Define IP2Location.io API key.
define('IP2LOCATION_IO_API_KEY', 'your_api_key');

// (optional) Define Translation information. Refer to https://www.ip2location.io/ip2location-documentation for available languages.
define('IP2LOCATION_IO_LANGUAGE', 'en');

// (optional) Define Translation information. Refer to https://www.ip2location.com/web-service/ip2location for available languages.
define('IP2LOCATION_LANGUAGE', 'en');

$IP2Location = new IP2Location_Yii();

$record = $IP2Location->get('8.8.8.8');
echo 'Result from BIN Database:';
echo 'IP Address: ' . $record['ipAddress'] . '';
echo 'IP Number: ' . $record['ipNumber'] . '';
echo 'ISO Country Code: ' . $record['countryCode'] . '';
echo 'Country Name: ' . $record['countryName'] . '';
echo 'Region Name: ' . $record['regionName'] . '';
echo 'City Name: ' . $record['cityName'] . '';
echo 'Latitude: ' . $record['latitude'] . '';
echo 'Longitude: ' . $record['longitude'] . '';
echo 'ZIP Code: ' . $record['zipCode'] . '';
echo 'Time Zone: ' . $record['timeZone'] . '';
echo 'ISP Name: ' . $record['isp'] . '';
echo 'Domain Name: ' . $record['domainName'] . '';
echo 'Net Speed: ' . $record['netSpeed'] . '';
echo 'IDD Code: ' . $record['iddCode'] . '';
echo 'Area Code: ' . $record['areaCode'] . '';
echo 'Weather Station Code: ' . $record['weatherStationCode'] . '';
echo 'Weather Station Name: ' . $record['weatherStationName'] . '';
echo 'MCC: ' . $record['mcc'] . '';
echo 'MNC: ' . $record['mnc'] . '';
echo 'Mobile Carrier Name: ' . $record['mobileCarrierName'] . '';
echo 'Elevation: ' . $record['elevation'] . '';
echo 'Usage Type: ' . $record['usageType'] . '';
echo 'Address Type: ' . $record['addressType'] . '';
echo 'Category: ' . $record['category'] . '';

$record = $IP2Location->getWebService('8.8.8.8');
echo 'Result from Web service:';
echo '';
print_r ($record);
echo '';

```

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

[](#dependencies)

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

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

You can also sign up for [IP2Location.io IP Geolocation API](https://www.ip2location.io/sign-up) to get one free API key.

SUPPORT
-------

[](#support)

Email:

Website:

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance51

Moderate activity, may be stable

Popularity25

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity50

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

Every ~1168 days

Total

2

Last Release

896d ago

### Community

Maintainers

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

---

Top Contributors

[![ip2location-com](https://avatars.githubusercontent.com/u/6367210?v=4)](https://github.com/ip2location-com "ip2location-com (9 commits)")

---

Tags

geolocationip-address-databaseip-databaseip-geolocationip-lookupip2locationip2location-bin-databasesweb-serviceyii2yii2-extensiongeolocationyii2ip2location

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[ip2location/ip2location-php

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

2133.9M33](/packages/ip2location-ip2location-php)[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)[midnite81/geolocation

A laravel package which wraps the IP Info DB and IP2Location Services

3624.1k](/packages/midnite81-geolocation)[ip2location/ip2location-cakephp

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.

224.6k](/packages/ip2location-ip2location-cakephp)[atchondjo/geoip2country

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

344.1k](/packages/atchondjo-geoip2country)[richardfan1126/yii2-js-register

Yii2 widget to register JS into view

1357.2k7](/packages/richardfan1126-yii2-js-register)

PHPackages © 2026

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