Composer-packaged version of the free MaxMind GeoLite2 Country database.

Installs: 14 473

Dependents: 0

Suggesters: 0

Security: 0

Stars: 21

Watchers: 2

Forks: 6

Open Issues: 3


v0.2.3 2017-02-10 16:03 UTC

This package is auto-updated.

Last update: 2021-09-15 22:42:33 UTC


Latest Stable Version Total Downloads Latest Unstable Version License

This is a Composer plugin that provides an automated binary version of the free MaxMind GeoLite2 Country database.

The main advantage is that the downloaded database will be checked for updates on each composer install and composer update.

Table Of Contents


This product includes GeoLite2 data created by MaxMind, available from


The only thing you need to do to make this work is adding this package as a dependency to your project:

composer require brightnucleus/geolite2-country

Basic Usage

On each composer install or composer update, a check will be made to see whether there's a new version of the database available. If there is, that new version is downloaded.

To retrieve the path to the binary database file from within your project, you can use the Database::getLocation() method:


use BrightNucleus\GeoLite2Country\Database;

$dbLocation = Database::getLocation();

You can pass this location on to the GeoIp2\Database\Reader class that is provided with the geoip2/geoip2 Composer package.


The following example assumes that you have added the geoip2/geoip2 Composer package as a dependency to your project, so that it is available to the autoloader.


use GeoIp2\Database\Reader;
use BrightNucleus\GeoLite2Country\Database;

function getCountry($ip) {
    $dbLocation = Database::getLocation();
    $reader = new Reader($dbLocation);

    return $reader->country($ip);


All feedback / bug reports / pull requests are welcome.


This code is released under the MIT license.

For the full copyright and license information, please view the LICENSE file distributed with this source code.