saeedvaziry/ip2location
Composer 安装命令:
composer require saeedvaziry/ip2location
包简介
IP to Location database
README 文档
README
IP2Location is a small Laravel package that converts IPs to location.
This package is a wrapper to IP2Location.
Installation
composer require saeedvaziry/ip2location
Configuration
Publish configs with the following command
php artisan vendor:publish --provider="SaeedVaziry\IP2Location\IP2LocationServiceProvider"
Then modify configs/ip2location.php to set your download URL from IP2Location's website
<?php return [ 'db_path' => 'database/bin/IP2LOCATION-LITE-DB1.BIN', 'download_url' => 'https://download.ip2location.com/lite/IP2LOCATION-LITE-DB1.BIN.ZIP', ];
Updating IP database
After the installation, you need to run the following command for updating the IP database.
php artisan ip2location:update
You can also set a scheduler in your app/Console/Kernel.php to keep it up to date.
Usage
Facade
You can use \SaeedVaziry\IP2Location\Facades\IP2Location facade to access to all supported methods.
// returns an array \SaeedVaziry\IP2Location\Facades\IP2Location::info($ipAddress); // returns the country full name \SaeedVaziry\IP2Location\Facades\IP2Location::countryName($ipAddress); // returns the country 2 character ISO code \SaeedVaziry\IP2Location\Facades\IP2Location::countryCode($ipAddress);
Helper functions
You may want to access to the methods via helper functions.
// returns an array ip2location_info($ipAddress); // returns the country full name ip2location_country_name($ipAddress); // returns the country 2 character ISO code ip2location_country_code($ipAddress);
If you don't pass the $ipAddress in both Facade and Helper, The method will extract the IP address from the Http request.
License
IP2Location is licensed under The MIT License (MIT).
saeedvaziry/ip2location 适用场景与选型建议
saeedvaziry/ip2location 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.27k 次下载、GitHub Stars 达 34, 最近一次更新时间为 2020 年 10 月 31 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 saeedvaziry/ip2location 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 saeedvaziry/ip2location 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 2.27k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 34
- 点击次数: 18
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-10-31