
IP2Location is a 3rd party provider which provides website owners the option to detect the actual location of the visitor i.e. country, city, postcode, ISP etc from the IP address of the visitor. They provide you several options to use their data to detect the visitor’s location.
For this example I will use the option of downloading a BIN file from their website and use it in my Laravel website. The integration process is quite straight forward and easy as well.
- First run the command:
composer require ip2location/ip2location-laravel
to download the package into the Laravel platform. - Edit
config/app.php
and add this line in ‘providers’ section:Ip2location\IP2LocationLaravel\IP2LocationLaravelServiceProvider::class
- Publish the config file by:
php artisan vendor:publish --provider=Ip2location\IP2LocationLaravel\IP2LocationLaravelServiceProvider --force
- Create a folder named as
ip2location
in thedatabase
directory. - Copy the IPV6-COUNTRY.BIN file into
database/ip2location/
folder. - Rename the BIN file to IP2LOCATION.BIN
Hope the above helped you.