1. Go to this page and download the library: Download qbcloud/laravel-geoip2 library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
qbcloud / laravel-geoip2 example snippets
// config/geoip2.php
return [
'lang' => 'zh-CN', // zh-CN en ru pt-BR ja fr es de
'db_type' => 'city', // city country asn db_type===city则db_path_city必填 db_type===country则db_path_country必填
'db_path_city' => 'geoip2/GeoLite2-City.mmdb', // 以 storage_path() 为根目录
'db_path_country' => 'geoip2/GeoLite2-Country.mmdb', // 以 storage_path() 为根目录
'db_path_asn' => 'geoip2/GeoLite2-ASN.mmdb' // 以 storage_path() 为根目录
];
use QbCloud\Geoip2\Facades\IPQuery;
// 查询 ipv4 或者 ipv6
IPQuery::connect('x.x.x.x');
// 或者
use QbCloud\Geoip2\IPQuery;
$client = new IPQuery();
$client->connect('2xx6:4xx0:0:1x3::a0');