formatd/geoip
Composer 安装命令:
composer require formatd/geoip
包简介
Neos integration for maxmind geoip2 client
README 文档
README
A Neos CMS Integration for the geolocation service geoip2 api client of Maxmind (maxmind.com).
What does it do?
This package provides a service-class and eel-helper to access the geo-information of a user (by analyzing the IP address with the maxmind api). Optionally you can integrate a prompt to redirect the user to the content dimension matching his current location.
Compatibility
Versioning scheme:
1.0.0
| | |
| | Bugfix Releases (non breaking)
| Neos Compatibility Releases (non breaking except framework dependencies)
Feature Releases (breaking)
Releases und compatibility:
| Package-Version | Neos CMS Version |
|---|---|
| 1.0.x | 4.x |
| 1.1.x | 5.x |
| 1.2.x | 7.x, 8.x |
Using the service in you own plugins
Inject the IPLocalizationService into your class and call the method according to the maxmind endpoint (getCountry, getCity, getInsights). the corresponding model of the geoip2 library holding all available information is returned.
Using the service in fusion
To get de country iso code in lowercase call this eel-helper.
${String.toLowerCase(FormatD.GeoIP.country())}
The eel-helper accepts an optional argument "key" (e.g. "continent.code") for direct access to the data provided by geoip2
Using the dimension switch prompt
To display a layer on your site telling the user to switch dimension if he is located somewhere else integrate this fusion prototype and place it where you need it.
- Place fusion prototype where you want it in your site
include: resource://FormatD.GeoIP/Private/Fusion/LocationBasedDimensionSwitchPrompt.fusion
page.someWhereInYourSite = FormatD.GeoIP:LocationBasedDimensionSwitchPrompt
-
Integrate LocationBasedDimensionSwitchPrompt.js into your site js bundling (it requires jQuery)
-
Configure the mapping (which iso code to what dimension value) in the Settings.yaml (see configuration)
-
Make it pretty with css
Configuration options
Set your maxmind credentials in the Settings.yaml
FormatD:
GeoIP:
geoIpUserId: 123456
geoIpLicense: 'somepassword'
For local testing you can enable debugging and simulate your ip address
FormatD:
GeoIP:
debug:
enable: true
simulateIpAddress: '8.8.8.8' # example us ip (google)
To make the LocationBasedDimensionSwitchPrompt work you have to configure which iso code you want to redirect to which dimension value.
FormatD:
GeoIP:
locationBasedDimensionSwitch:
dimensionName: 'country'
countryIsoCodeToPresetMap:
gb: 'uk'
de: 'de'
Calls to the API are cached for one day. You can modify the default lifetime in your Caches.yaml
formatd/geoip 适用场景与选型建议
formatd/geoip 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 853 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 03 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 formatd/geoip 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 formatd/geoip 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 853
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-03-21