chintanlin / laravel-geoip2
为 Laravel 提供的 geoip2 插件
v1.0.0
2020-07-09 13:11 UTC
Requires
- geoip2/geoip2: ^2.10
- guzzlehttp/guzzle: ^6.3
Requires (Dev)
- orchestra/testbench: ^5.3
This package is auto-updated.
Last update: 2024-09-11 02:05:00 UTC
README
GeoIP2 for Laravel
composer require chintanlin/laravel-geoip2
如何使用
GeoIP2::getCountry('8.8.8.8'); // Facades app('geoip2')->getCountry('8.8.8.8'); // Providers geoip2('8.8.8.8'); // helpers // use maxmind/GeoIP2 PHP API directly $record = GeoIP2::city('8.8.8.8'); $record->country->name;
更新数据库
数据库文件存储在 storage_path('app/GeoLite2-City.mmdb')
例如:Laravel/storage/app/GeoLite2-City.mmdb
你应在 .env 文件中使用您的私有许可证密钥(MAXMIND_LICENSE=xxxx)
php artisan geoip2:update;