• Your shopping cart is empty!

IP2Location PHP Module

This module is a PHP module that enables the user to find the country, region, city, coordinates, ZIP code, ISP, domain name, timezone, connection speed, IDD code, area code, weather station code, weather station name, MCC, MNC, mobile brand name, elevation and usage type that any IP address or host name originates from. It has been optimized for speed and memory utilization. Developers can use the API to query all IP2Location™ binary databases for IPv4 and IPv6 address.

Installation
  1. Add the below line into your composer.json file.
    {
      "require": {
    	"ip2location/ip2location-php": "8.*"
      }
    }
  2. Run the command:
    composer install

    Note: You just need to include the below code in order to use the library.
    require 'vendor/autoload.php';
Sample Codes
<?php
require 'IP2Location.php';

/*
   Cache whole database into system memory and share among other scripts & websites
   WARNING: Please make sure your system have sufficient RAM to enable this feature
*/
// $db = new \IP2Location\Database('./database/IP-COUNTRY-SAMPLE.BIN', \IP2Location\Database::SHARED_MEMORY);
/*
   Cache the database into memory to accelerate lookup speed
   WARNING: Please make sure your system have sufficient RAM to enable this feature
*/
// $db = new \IP2Location\Database('./database/IP-COUNTRY-SAMPLE.BIN', \IP2Location\Database::MEMORY_CACHE);


/*
	Default file I/O lookup
*/
$db = new \IP2Location\Database('./database/IP-COUNTRY-SAMPLE.BIN', \IP2Location\Database::FILE_IO);

$records = $db->lookup('8.8.8.8', \IP2Location\Database::ALL);

echo '<pre>';
echo 'IP Number             : ' . $records['ipNumber'] . "\n";
echo 'IP Version            : ' . $records['ipVersion'] . "\n";
echo 'IP Address            : ' . $records['ipAddress'] . "\n";
echo 'Country Code          : ' . $records['countryCode'] . "\n";
echo 'Country Name          : ' . $records['countryName'] . "\n";
echo 'Region Name           : ' . $records['regionName'] . "\n";
echo 'City Name             : ' . $records['cityName'] . "\n";
echo 'Latitude              : ' . $records['latitude'] . "\n";
echo 'Longitude             : ' . $records['longitude'] . "\n";
echo 'Area Code             : ' . $records['areaCode'] . "\n";
echo 'IDD Code              : ' . $records['iddCode'] . "\n";
echo 'Weather Station Code  : ' . $records['weatherStationCode'] . "\n";
echo 'Weather Station Name  : ' . $records['weatherStationName'] . "\n";
echo 'MCC                   : ' . $records['mcc'] . "\n";
echo 'MNC                   : ' . $records['mnc'] . "\n";
echo 'Mobile Carrier        : ' . $records['mobileCarrierName'] . "\n";
echo 'Usage Type            : ' . $records['usageType'] . "\n";
echo 'Elevation             : ' . $records['elevation'] . "\n";
echo 'Net Speed             : ' . $records['netSpeed'] . "\n";
echo 'Time Zone             : ' . $records['timeZone'] . "\n";
echo 'ZIP Code              : ' . $records['zipCode'] . "\n";
echo 'Domain Name           : ' . $records['domainName'] . "\n";
echo 'ISP Name              : ' . $records['isp'] . "\n";
echo '</pre>';
?>
Sample IP2Location Databases (BIN)
Sample Packages IPv4 IPV6
IP2Location DB1 Sample BIN File Download (694.32 kB) Download (350.84 kB)
IP2Location DB2 Sample BIN File Download (36.68 MB) Download (378.66 kB)
IP2Location DB3 Sample BIN File Download (19.27 MB) Download (363.65 kB)
IP2Location DB4 Sample BIN File Download (52.81 MB) Download (388.27 kB)
IP2Location DB5 Sample BIN File Download (29.31 MB) Download (370.18 kB)
IP2Location DB6 Sample BIN File Download (62.40 MB) Download (393.44 kB)
IP2Location DB7 Sample BIN File Download (58.67 MB) Download (398.64 kB)
IP2Location DB8 Sample BIN File Download (68.50 MB) Download (403.55 kB)
IP2Location DB9 Sample BIN File Download (33.72 MB) Download (373.45 kB)
IP2Location DB10 Sample BIN File Download (73.75 MB) Download (408.65 kB)
IP2Location DB11 Sample BIN File Download (34.39 MB) Download (374.17 kB)
IP2Location DB12 Sample BIN File Download (74.37 MB) Download (409.59 kB)
IP2Location DB13 Sample BIN File Download (33.00 MB) Download (371.65 kB)
IP2Location DB14 Sample BIN File Download (75.66 MB) Download (410.29 kB)
IP2Location DB15 Sample BIN File Download (37.30 MB) Download (378.07 kB)
IP2Location DB16 Sample BIN File Download (80.17 MB) Download (415.93 kB)
IP2Location DB17 Sample BIN File Download (39.79 MB) Download (380.09 kB)
IP2Location DB18 Sample BIN File Download (87.04 MB) Download (425.95 kB)
IP2Location DB19 Sample BIN File Download (71.17 MB) Download (404.88 kB)
IP2Location DB20 Sample BIN File Download (89.44 MB) Download (427.07 kB)
IP2Location DB21 Sample BIN File Download (40.59 MB) Download (380.72 kB)
IP2Location DB22 Sample BIN File Download (93.37 MB) Download (430.11 kB)
IP2Location DB23 Sample BIN File Download (71.51 MB) Download (405.90 kB)
IP2Location DB24 Sample BIN File Download (94.25 MB) Download (431.79 kB)