neto737/geoip2-update

Update GeoIP2/GeoLite2 databases from your script, program or via composer.

Maintainers

Package info

github.com/neto737/geoip2-update

pkg:composer/neto737/geoip2-update

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-06-13 15:08 UTC

This package is auto-updated.

Last update: 2026-06-13 15:17:13 UTC


README

Update GeoIP2/GeoLite2 databases from your PHP script or automatically via Composer.

Requirements

  • PHP 8.3+
  • ext-curl
  • ext-zip (only required for CSV database editions)
  • A valid MaxMind license key

Installation

composer require neto737/geoip2-update

Usage

1. Automatic updates via Composer

Add the configuration to your project's composer.json. The databases will be checked and updated every time composer update or composer update neto737/geoip2-update runs.

{
    "scripts": {
        "post-update-cmd": "neto737\\GeoIP2Update\\ComposerClient::run"
    },
    "extra": {
        "neto737\\GeoIP2Update\\ComposerClient::run": {
            "license_key": "YOUR_LICENSE_KEY",
            "dir": "@composer/../geoip2"
        }
    }
}

The @composer token is replaced with the directory of your composer.json file.

2. Programmatic updates from PHP

use neto737\GeoIP2Update\Client;

$client = new Client([
    'license_key' => 'YOUR_LICENSE_KEY',
    'dir'         => '/path/to/geoip2',
    'editions'    => ['GeoLite2-ASN', 'GeoLite2-City', 'GeoLite2-Country'],
]);

$client->run();

foreach ($client->updated() as $message) {
    echo $message . PHP_EOL;
}

foreach ($client->errors() as $error) {
    echo 'Error: ' . $error . PHP_EOL;
}

3. Loading the configuration from a GeoIP.conf file

$client = new Client([
    'geoipConfFile' => '/etc/GeoIP.conf',
    'dir'           => '/path/to/geoip2',
]);

$client->run();

The GeoIP.conf file is the standard MaxMind configuration format:

AccountID  12345
LicenseKey YOUR_LICENSE_KEY
EditionIDs GeoLite2-ASN GeoLite2-City GeoLite2-Country

Configuration options

Option Type Description
license_key string Your MaxMind license key
dir string Directory where database files will be stored
editions string[] List of edition IDs to update (see below)
geoipConfFile string Path to a GeoIP.conf file (sets license_key and editions)

Supported editions

Edition ID Format
GeoLite2-ASN MMDB
GeoLite2-City MMDB
GeoLite2-Country MMDB
GeoIP2-ASN MMDB
GeoIP2-City MMDB
GeoIP2-Country MMDB
GeoLite2-ASN-CSV ZIP
GeoLite2-City-CSV ZIP
GeoLite2-Country-CSV ZIP
GeoIP2-ASN-CSV ZIP
GeoIP2-City-CSV ZIP
GeoIP2-Country-CSV ZIP

CSV editions require ext-zip.

License

MIT — see LICENSE.