neto737/geoip2-update
Composer 安装命令:
composer require neto737/geoip2-update
包简介
Update GeoIP2/GeoLite2 databases from your script, program or via composer.
README 文档
README
Update GeoIP2/GeoLite2 databases from your PHP script or automatically via Composer.
Requirements
- PHP 8.3+
ext-curlext-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.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-06-13