diff --git a/README.md b/README.md index 9c4a6d2..729cc65 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,21 @@ IP2Location Laravel extension enables the user to find the country, region, city 4. Download IP2Location BIN database - IP2Location free LITE database at https://lite.ip2location.com - IP2Location commercial database at https://www.ip2location.com -5. Create a folder named as `ip2location` in the `database` directory. +5. To use IP2Location databases, create a folder named as `ip2location` in the `database` directory. 6. Unzip and copy the BIN file into `database/ip2location/` folder. 7. Rename the BIN file to IP2LOCATION.BIN. +8. To use IP2Location web service, create a new file called "site_vars.php" in `config` directory. +9. In the site_vars.php, save the following contents: +```php + 'your_api_key', // Required. Your IP2Location API key. + 'IP2LocationPackage' => 'WS1', // Required. Choose the package you would like to use. + 'IP2LocationUsessl' => false, // Optional. Use https or http. + 'IP2LocationAddons' => [], // Optional. Refer to https://www.ip2location.com/web-service/ip2location for the list of available addons. + 'IP2LocationLanguage' => 'en', // Optional. Refer to https://www.ip2location.com/web-service/ip2location for available languages. +]; +``` ## USAGE @@ -29,8 +41,8 @@ In this tutorial, we will show you on how to create a **TestController** to disp php artisan make:controller TestController ``` 2. Open the **app/Http/Controllers/TestController.php** in any text editor. -3. Add the below lines into the controller file. -``` +3. To use IP2Location databases, add the below lines into the controller file. +```php "; + echo 'Country Name : ' . $records['country_name'] . "
"; + echo 'Region Name : ' . $records['region_name'] . "
"; + echo 'City Name : ' . $records['city_name'] . "
"; + echo 'Latitude : ' . $records['latitude'] . "
"; + echo 'Longitude : ' . $records['longitude'] . "
"; + echo 'Area Code : ' . $records['area_code'] . "
"; + echo 'IDD Code : ' . $records['idd_code'] . "
"; + echo 'Weather Station Code : ' . $records['weather_station_code'] . "
"; + echo 'Weather Station Name : ' . $records['weather_station_name'] . "
"; + echo 'MCC : ' . $records['mcc'] . "
"; + echo 'MNC : ' . $records['mnc'] . "
"; + echo 'Mobile Carrier : ' . $records['mobile_brand'] . "
"; + echo 'Usage Type : ' . $records['usage_type'] . "
"; + echo 'Elevation : ' . $records['elevation'] . "
"; + echo 'Net Speed : ' . $records['net_speed'] . "
"; + echo 'Time Zone : ' . $records['time_zone'] . "
"; + echo 'ZIP Code : ' . $records['zip_code'] . "
"; + echo 'Domain Name : ' . $records['domain'] . "
"; + echo 'ISP Name : ' . $records['isp'] . "
"; + echo 'Credits Consumed : ' . $records['credits_consumed'] . "
"; + } +} + +``` +5. Add the following line into the *routes/web.php* file. ``` Route::get('test', 'TestController@lookup'); ``` 5. Enter the URL /public/test and run. You should see the information of **8.8.8.8** IP address. -## DEPENDENCIES (IP2LOCATION BIN DATA FILE) +## DEPENDENCIES -This library requires IP2Location BIN data file to function. You may download the BIN data file at +This library requires either IP2Location BIN data file or IP2Location API key to function. You may download the BIN data file at * IP2Location LITE BIN Data (Free): https://lite.ip2location.com * IP2Location Commercial BIN Data (Comprehensive): https://www.ip2location.com +For IP2Location API key, you can sign up [IP2Location Web Service](https://www.ip2location.com/web-service/ip2location) to get one free API key. + ## IPv4 BIN vs IPv6 BIN Use the IPv4 BIN file if you just need to query IPv4 addresses. diff --git a/composer.json b/composer.json index 985933d..f30cab3 100644 --- a/composer.json +++ b/composer.json @@ -5,6 +5,7 @@ "keywords": [ "laravel", "laravel 5", + "laravel 7", "IP2Location", "geolocation" ], diff --git a/license.txt b/license.txt index 1ebca50..1f446b9 100644 --- a/license.txt +++ b/license.txt @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2017 IP2Location.com +Copyright (c) 2020 IP2Location.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal