承接 sourcebroker/ip2geo 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sourcebroker/ip2geo

Composer 安装命令:

composer require sourcebroker/ip2geo

包简介

Returns geo data based on IP - uses Maxmind databases (free/commercial)

README 文档

README

https://poser.pugx.org/sourcebroker/ip2geo/license

What does it do?

This extension provides scheduler job to download maxmind database (free or commercial) and some small class with methods to get interesting content like country, continent etc.

How to install?

  1. Install using composer:

    composer require sourcebroker/ip2geo
    
  2. Go to Scheduler module and add new job "Download geolocation database"

  3. While adding scheduler job you need two parameters:

    1. Database name. This can an be any string. Example: "freeCountry", "commercialCountry". This name will be used later in php code like GeoIp::getInstance('freeCountry') .
    2. Download URL. Maxmind database download link.
  4. Run the scheduler and check folder /uploads/tx_ip2geo/. The database should be downloaded there.

How to use?

In your code get the data with following call:

  1. For country database:

    $countryCode = GeoIp::getInstance('freeCountry')->getCountryCode(); // assuming you named database with "freeCountry" in scheduler task
    

    For IP 83.97.23.149 you will get "DE" as response:

  2. For city database:

    $locationData = GeoIp::getInstance('freeCity')->getLocation(); // assuming you named database with "freeCity" in scheduler task
    

    For IP 83.97.23.149 you will get following data as response:

    Array
    (
       [continentCode] => EU
       [countryCode] => DE
       [countryName] => Germany
       [city] => Berlin
       [postalCode] => 10178
       [latitude] => 52.5196
       [longitude] => 13.4069
    )
    

Additional options

You can set some options for this extension in $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ip2geo']. You can use typo3conf/LocalConfiguration file to store this values.

  1. defaultLocalIP For local development you IP is usually 127.0.0.1 and this IP of course does not exist in Maxmind database. For this situation Maxminf API will return "The address 127.0.0.1 is not in the database.". You can fix it by setting default IP if the IP is detected as 127.0.0.1. Example configuration:

    'EXTCONF' => [
      'ip2geo' => [
        'defaultLocalIP' => '83.97.23.149',
      ],
    ],
    
  2. fakeIpHeaderName This is a name of header which you can use to overwrite the value of IP. This value must be unique so nobody except you can overwrite IP. TIP: a nice chrome extension for setting headers is "ModHeader". Example:

    'EXTCONF' => [
      'ip2geo' => [
        'fakeIpHeaderName' => 'myFakeIpHeader1991718263162831',
      ],
    ],
    

fakeIpHeaderName has precedence over defaultLocalIP when both are set.

Changelog

See https://github.com/sourcebroker/ip2geo/blob/master/CHANGELOG.rst

sourcebroker/ip2geo 适用场景与选型建议

sourcebroker/ip2geo 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.13k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2019 年 07 月 17 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 sourcebroker/ip2geo 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 sourcebroker/ip2geo 我们能提供哪些服务?
定制开发 / 二次开发

基于 sourcebroker/ip2geo 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 3.13k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2019-07-17