[extension] ip2location/ip2proxy-yii


IP2Proxy Yii extension

  1. INSTALLATION
  2. USAGE
  3. DEPENDENCIES
  4. SUPPORT

IP2Proxy Yii extension enables the user to query an IP address if it was being used as open proxy, web proxy, VPN anonymizer and TOR exit nodes, search engine robots, data center ranges and residential proxies. It lookup the proxy IP address from IP2Proxy BIN Data file or web service. Developers can use the API to query all IP2Proxy BIN databases or web service for applications written using Yii.
INSTALLATION For Yii2

  1. Run the command: php composer.phar require ip2location/ip2proxy-yii to download the plugin into the Yii2 framework.
  2. Download latest IP2Proxy BIN database
  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 use IP2ProxyYii\IP2Proxy_Yii;

// (required) Define IP2Proxy database path.
define('IP2PROXY_DATABASE', '/path/to/ip2proxy/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');

// (required) Define IP2Proxy API key.
define('IP2PROXY_API_KEY', 'your_api_key');

// (required) Define IP2Proxy Web service package of different granularity of return information.
define('IP2PROXY_PACKAGE', 'PX1');

// (optional) Define to use https or http.
define('IP2PROXY_USESSL', false);

$IP2Proxy = new IP2Proxy_Yii();

$record = $IP2Proxy->get('1.0.241.135');
echo 'Result from BIN Database:';
echo 'IP Address: ' . $record['ipAddress'] . '';
echo 'IP Number: ' . $record['ipNumber'] . '';
echo 'IP Version: ' . $record['ipVersion'] . '';
echo 'Country Code: ' . $record['countryCode'] . '';
echo 'Country: ' . $record['countryName'] . '';
echo 'State: ' . $record['regionName'] . '';
echo 'City: ' . $record['cityName'] . '';
echo 'Proxy Type: ' . $record['proxyType'] . '';
echo 'Is Proxy: ' . $record['isProxy'] . '';
echo 'ISP: ' . $record['isp'] . '';
echo 'Domain: ' . $record['domain'] . '';
echo 'Usage Type: ' . $record['usageType'] . '';
echo 'ASN: ' . $record['asn'] . '';
echo 'AS: ' . $record['as'] . '';
echo 'Last Seen: ' . $record['lastSeen'] . '';
echo 'Threat: ' . $record['threat'] . '';
echo 'Provider: ' . $record['provider'] . '';

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

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

You can also sign up for IP2Proxy Web Service or IP2Location.io IP GEOLOCATION API to get one free API key.
SUPPORT Email: support@ip2location.com
Website: https://www.ip2location.com