GeoIP is a way to get location from an IP.

In PHP there are many ways to get that but the best way to get that is to keep the MaxMind database and use that.

first, we need

composer require geoip2/geoip2


Download “geoip.mmdb” database from MaxMind


use GeoIp2\Database\Reader;

require_once './vendor/autoload.php';

$reader = new Reader('./geoip.mmdb');

 $record = $reader->city('');

Download MaxMind City database from Github

To use this easily with other providers you can use “torann/geoip

Ahmad Eyamin