Package Data | |
---|---|
Maintainer Username: | ip2location |
Maintainer Contact: | support@ip2location.com (IP2Location) |
Package Create Date: | 2017-01-25 |
Package Last Update: | 2024-10-08 |
Home Page: | http://www.ip2location.com |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-14 15:02:53 |
Package Statistics | |
---|---|
Total Downloads: | 378,430 |
Monthly Downloads: | 8,126 |
Daily Downloads: | 359 |
Total Stars: | 78 |
Total Watchers: | 9 |
Total Forks: | 13 |
Total Open Issues: | 0 |
IP2Location Laravel 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 and usage type that any IP address or hostname originates from. It has been optimized for speed and memory utilization.
composer require ip2location/ip2location-laravel
to download the package into the Laravel platform.config/app.php
and add the below line in 'providers' section:Ip2location\IP2LocationLaravel\IP2LocationLaravelServiceProvider::class,
php artisan vendor:publish --provider=Ip2location\IP2LocationLaravel\IP2LocationLaravelServiceProvider --force
ip2location
in the database
directory.database/ip2location/
folder.In this tutorial, we will show you on how to create a TestController to display the IP information.
php artisan make:controller TestController
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use IP2LocationLaravel; //use IP2LocationLaravel class
class TestController extends Controller
{
//Create a lookup function for display
public function lookup(){
//Try query the geolocation information of 8.8.8.8 IP address
$records = IP2LocationLaravel::get('8.8.8.8');
echo 'IP Number : ' . $records['ipNumber'] . "<br>";
echo 'IP Version : ' . $records['ipVersion'] . "<br>";
echo 'IP Address : ' . $records['ipAddress'] . "<br>";
echo 'Country Code : ' . $records['countryCode'] . "<br>";
echo 'Country Name : ' . $records['countryName'] . "<br>";
echo 'Region Name : ' . $records['regionName'] . "<br>";
echo 'City Name : ' . $records['cityName'] . "<br>";
echo 'Latitude : ' . $records['latitude'] . "<br>";
echo 'Longitude : ' . $records['longitude'] . "<br>";
echo 'Area Code : ' . $records['areaCode'] . "<br>";
echo 'IDD Code : ' . $records['iddCode'] . "<br>";
echo 'Weather Station Code : ' . $records['weatherStationCode'] . "<br>";
echo 'Weather Station Name : ' . $records['weatherStationName'] . "<br>";
echo 'MCC : ' . $records['mcc'] . "<br>";
echo 'MNC : ' . $records['mnc'] . "<br>";
echo 'Mobile Carrier : ' . $records['mobileCarrierName'] . "<br>";
echo 'Usage Type : ' . $records['usageType'] . "<br>";
echo 'Elevation : ' . $records['elevation'] . "<br>";
echo 'Net Speed : ' . $records['netSpeed'] . "<br>";
echo 'Time Zone : ' . $records['timeZone'] . "<br>";
echo 'ZIP Code : ' . $records['zipCode'] . "<br>";
echo 'Domain Name : ' . $records['domainName'] . "<br>";
echo 'ISP Name : ' . $records['isp'] . "<br>";
}
}
Route::get('test', 'TestController@lookup');
This library requires IP2Location BIN data file to function. You may download the BIN data file at
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.
Email: support@ip2location.com
Website: https://www.ip2location.com