cyber-duck / laravel-maxmind-geolocate
Laravel 包,用于利用 MaxMind GeoLite2 数据库进行基于 IP 的地理位置定位
v1.0.2
2023-07-26 10:55 UTC
Requires
- php: ^8.1
- geoip2/geoip2: ^2.13
- guzzlehttp/guzzle: ^7.5
- illuminate/console: ^8.0|^9.0|^10.0
- illuminate/support: ^8.67|^9.0|^10.0
Requires (Dev)
- orchestra/testbench: ^8.5
This package is auto-updated.
Last update: 2024-09-08 10:45:48 UTC
README
此包利用 MaxMind GeoLite 数据库,允许对 IP 地址进行地理位置定位。
控制台命令
php artisan geolocation:update
从 MaxMind 下载数据库的最新存档,验证哈希值,并存储在配置中指定的远程磁盘(例如 S3)上。
php artisan geolocation:fetch
获取、提取并将之前存储在远程磁盘(例如 S3)上的存档移动到应用程序存储中。
使用方法
一旦数据库已下载并提取到应用程序本地存储目录中,要定位 IP 地址,请使用提供的门面,如下所示
use CyberDuck\GeoLocate\Facades\GeoLocate; $result = GeoLocate::country('1.2.3.4'); // $result is an instance of \GeoIp2\Record\Country $result->isoCode // == 'GB' for example.