PHPackages                             dotkernel/dot-geoip - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. dotkernel/dot-geoip

ActiveLibrary

dotkernel/dot-geoip
===================

Dotkernel component based on Maxmind's geoip2/geoip2 package, using their free GeoLite2 databases to provide geographical details about an IP address.

3.11.0(5mo ago)510.5k↑287.5%21MITPHPPHP ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0CI passing

Since Nov 28Pushed 5mo ago3 watchersCompare

[ Source](https://github.com/dotkernel/dot-geoip)[ Packagist](https://packagist.org/packages/dotkernel/dot-geoip)[ RSS](/packages/dotkernel-dot-geoip/feed)WikiDiscussions 3.0 Synced 1mo ago

READMEChangelog (10)Dependencies (8)Versions (30)Used By (1)

dot-geoip
=========

[](#dot-geoip)

Dotkernel component to provide geographical details about an IP address

> dot-geoip is a wrapper on top of [maxmind/GeoIP2-php](https://github.com/maxmind/GeoIP2-php)

Documentation
-------------

[](#documentation)

Documentation is available at: .

Badges
------

[](#badges)

[![OSS Lifecycle](https://camo.githubusercontent.com/261d805638991823ffac4de3f9fe5ae9aa87e2b36dec3d2fcf489809480f52ad/68747470733a2f2f696d672e736869656c64732e696f2f6f73736c6966656379636c652f646f746b65726e656c2f646f742d67656f6970)](https://camo.githubusercontent.com/261d805638991823ffac4de3f9fe5ae9aa87e2b36dec3d2fcf489809480f52ad/68747470733a2f2f696d672e736869656c64732e696f2f6f73736c6966656379636c652f646f746b65726e656c2f646f742d67656f6970)[![PHP from Packagist (specify version)](https://camo.githubusercontent.com/ee40172ac4fa57559f28de2ebb980c5c5fd442e042609d4da88c7db3c5ea72c2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f646f746b65726e656c2f646f742d67656f69702f332e31312e30)](https://camo.githubusercontent.com/ee40172ac4fa57559f28de2ebb980c5c5fd442e042609d4da88c7db3c5ea72c2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f646f746b65726e656c2f646f742d67656f69702f332e31312e30)

[![GitHub issues](https://camo.githubusercontent.com/72af5138e9ed973a3f4c2873d550d4fd8b9f87024836af78fc968762a756f39a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f646f746b65726e656c2f646f742d67656f6970)](https://github.com/dotkernel/dot-geoip/issues)[![GitHub forks](https://camo.githubusercontent.com/7759a5982f043de3a4adeb391458ff7b02ccde2e0c00c9dfd1d7795009739712/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f646f746b65726e656c2f646f742d67656f6970)](https://github.com/dotkernel/dot-geoip/network)[![GitHub stars](https://camo.githubusercontent.com/b9d2bab7651d0244fb3f0d1417dcf3111b06ea524b6fd16850a284b215cb3620/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f646f746b65726e656c2f646f742d67656f6970)](https://github.com/dotkernel/dot-geoip/stargazers)[![GitHub license](https://camo.githubusercontent.com/1b3056f60b0e772bfc55c6136bea18303394e0e33fe49ba72211f99ae2926c74/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f646f746b65726e656c2f646f742d67656f6970)](https://github.com/dotkernel/dot-geoip/blob/3.0/LICENSE)

[![Build Static](https://github.com/dotkernel/dot-geoip/actions/workflows/continuous-integration.yml/badge.svg?branch=3.0)](https://github.com/dotkernel/dot-geoip/actions/workflows/continuous-integration.yml)[![codecov](https://camo.githubusercontent.com/2c5bc3731af57ccc973347230a0baeb02a638228ab945f0ba5f6c06cbcb05813/68747470733a2f2f636f6465636f762e696f2f67682f646f746b65726e656c2f646f742d67656f69702f67726170682f62616467652e7376673f746f6b656e3d4b34373350374d445a34)](https://codecov.io/gh/dotkernel/dot-geoip)[![PHPStan](https://github.com/dotkernel/dot-geoip/actions/workflows/static-analysis.yml/badge.svg?branch=3.0)](https://github.com/dotkernel/dot-geoip/actions/workflows/static-analysis.yml)

Install
-------

[](#install)

You can install this library by running the following command:

```
composer require dotkernel/dot-geoip
```

If your application didn't already use it, the above command also installed [dotkernel/dot-cli](https://github.com/dotkernel/dot-cli). In this case, see its [README](https://github.com/dotkernel/dot-cli/blob/3.0/README.md) file on how to use it.

Copy config file `vendor/dotkernel/dot-geoip/config/autoload/geoip.global.php` into your application's `config/autoload` directory.

Register the library's ConfigProvider by adding the following line to your application's `config/config.php` file:

```
Dot\GeoIP\ConfigProvider::class,
```

Register the library's synchronizer command by adding the following line to your application's `config/autoload/cli.global.php` file under the `commands` array key:

```
Dot\GeoIP\Command\GeoIpCommand::getDefaultName() => Dot\GeoIP\Command\GeoIpCommand::class,
```

Manage GeoLite2 database
------------------------

[](#manage-geolite2-database)

You can download/update a specific GeoLite2 database by running the following command:

```
php ./bin/cli.php geoip:synchronize -d {DATABASE}
```

Where *{DATABASE}* takes one of the following values: `asn`, `city`, `country`.

You can download/update all GeoLite2 databases at once by running the following command:

```
php ./bin/cli.php geoip:synchronize
```

The output should be similar to the below, displaying per row: `database identifier`: `previous build datetime` -&gt; `current build datetime`.

```
asn: n/a -> 2021-07-01 02:09:34
city: n/a -> 2021-07-01 02:09:20
country: n/a -> 2021-07-01 02:05:12

```

Get help for this command by running `php ./bin/cli.php help geoip:synchronize`.

> If you set up the synchronizer command as a cronjob, you can add the `-q|--quiet` option, and it will output data only if an error has occurred.

Usage
-----

[](#usage)

Below is an example implementation of using DotGeoip to retrieve information about an IP address.

```
