|
| 1 | +# IP2Proxy Laravel Extension |
| 2 | + |
| 3 | +IP2Proxy Laravel extension enables the user to query an IP address if it was being used as open proxy, web proxy, VPN anonymizer and TOR exits. |
| 4 | + |
| 5 | + |
| 6 | +## INSTALLATION |
| 7 | + |
| 8 | +1. Run the command: `composer require ip2location/ip2proxy-laravel` to download the package into the Laravel platform. |
| 9 | +2. Edit `config/app.php` and add the below line in 'providers' section: |
| 10 | +`Ip2location\IP2ProxyLaravel\IP2ProxyLaravelServiceProvider::class,` |
| 11 | +3. Then publish the config file by: |
| 12 | +`php artisan vendor:publish --provider=Ip2location\IP2ProxyLaravel\IP2ProxyLaravelServiceProvider --force` |
| 13 | +4. Download IP2Proxy BIN database |
| 14 | + - IP2Proxy free LITE database at http://lite.ip2location.com |
| 15 | + - IP2Proxy commercial database at http://www.ip2location.com/proxy-database |
| 16 | +5. Create a folder named as `ip2proxy` in the `database` directory. |
| 17 | +6. Unzip and copy the BIN file into `database/ip2proxy/` folder. |
| 18 | +7. Rename the BIN file to IP2PROXY.BIN. |
| 19 | + |
| 20 | + |
| 21 | +## USAGE |
| 22 | + |
| 23 | +In this tutorial, we will show you on how to create a **TestController** to display the IP information. |
| 24 | + |
| 25 | +1. Create a **TestController** in Laravel using the below command line |
| 26 | +``` |
| 27 | +php artisan make:controller TestController |
| 28 | +``` |
| 29 | +2. Open the **app/Http/Controllers/TestController.php** in any text editor. |
| 30 | +3. Add the below lines into the controller file. |
| 31 | +``` |
| 32 | +<?php |
| 33 | +
|
| 34 | +namespace App\Http\Controllers; |
| 35 | +
|
| 36 | +use Illuminate\Http\Request; |
| 37 | +use IP2ProxyLaravel; //use IP2ProxyLaravel class |
| 38 | +
|
| 39 | +class TestController extends Controller |
| 40 | +{ |
| 41 | + //Create a lookup function for display |
| 42 | + public function lookup(){ |
| 43 | + //Try query the geolocation information of 1.2.3.4 IP address |
| 44 | + $record = IP2ProxyLaravel::get('1.2.3.4'); |
| 45 | +
|
| 46 | + echo '<p><strong>IP Address: </strong>' . $record['ipAddress'] . '</p>'; |
| 47 | + echo '<p><strong>IP Number: </strong>' . $record['ipNumber'] . '</p>'; |
| 48 | + echo '<p><strong>IP Version: </strong>' . $record['ipVersion'] . '</p>'; |
| 49 | + echo '<p><strong>Country Code: </strong>' . $record['countryCode'] . '</p>'; |
| 50 | + echo '<p><strong>Country: </strong>' . $record['countryName'] . '</p>'; |
| 51 | + echo '<p><strong>State: </strong>' . $record['regionName'] . '</p>'; |
| 52 | + echo '<p><strong>City: </strong>' . $record['cityName'] . '</p>'; |
| 53 | + echo '<p><strong>Proxy Type: </strong>' . $record['proxyType'] . '</p>'; |
| 54 | + echo '<p><strong>Is Proxy: </strong>' . $record['isProxy'] . '</p>'; |
| 55 | + echo '<p><strong>ISP: </strong>' . $record['isp'] . '</p>'; |
| 56 | + } |
| 57 | +} |
| 58 | +``` |
| 59 | +4. Add the following line into the *routes/web.php* file. |
| 60 | +``` |
| 61 | +Route::get('test', 'TestController@lookup'); |
| 62 | +``` |
| 63 | +5. Enter the URL <your domain>/public/test and run. You should see the information of **1.2.3.4** IP address. |
| 64 | + |
| 65 | +## DEPENDENCIES (IP2PROXY BIN DATA FILE) |
| 66 | + |
| 67 | +This library requires IP2Proxy BIN data file to function. You may download the BIN data file at |
| 68 | +* IP2Proxy LITE BIN Data (Free): http://lite.ip2location.com |
| 69 | +* IP2Proxy Commercial BIN Data (Comprehensive): http://www.ip2location.com/proxy-database |
| 70 | + |
| 71 | + |
| 72 | +## SUPPORT |
| 73 | + |
| 74 | + |
| 75 | + |
| 76 | +Website: http://www.ip2location.com |
0 commit comments