承接 overals/yii2-geoip2 相关项目开发

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

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

overals/yii2-geoip2

最新稳定版本:1.0.2

Composer 安装命令:

composer require overals/yii2-geoip2

包简介

Yii2 GeoIP2 extension. Returns country, city, latitude, longitude, time zone, iso code, continent, subdivisions by IP (uses MaxMind's GeoIP2 databases)

README 文档

README

Provides information about geographical location of user by IP address.

Currently available:

  • Country
  • City
  • Latitude, Longitude
  • Time Zone
  • ISO Code
  • Continent
  • Subdivisions

Installation

$ php composer.phar require overals/yii2-geoip2 "~1.0.1"

OR

Add to your composer.json

{
    "require": {
        "overals/yii2-geoip2": "~1.0.1"
    }
}

and run

$ composer update

Usage

Update your config file - config/web.php

<?php

$config = [
    ...
    'components' => [
        'geoip2' => [
            'class' => 'overals\GeoIP2\GeoIP2',
            'mmdb' => '@app/components/GeoIP2/GeoLite2-City.mmdb',
            'lng' => 'en', // available languages = 'de', 'en', 'es', 'ja', 'ru', 'zh-CN'
        ],
    ]
    ...
];

somewhere in code:

$ip = Yii::$app->component->geoip2->getInfoByIP(); // current user ip
$ip = Yii::$app->component->geoip2->getInfoByIP("8.8.8.8");

$ip->continent; // "North America"
$ip->country; // "United States"
$ip->isoCode; // "US"
$ip->subdivisions; // "California"
$ip->city; // "Mountain View"
$ip->location->longitude; // -122.0838
$ip->location->latitude; // 37.386

This product uses GeoLite2 data created by MaxMind, available from http://www.maxmind.com

Where you can download Maxmind Free DBs?

From http://dev.maxmind.com/geoip/geoip2/geolite2/

OR

    cd /usr/local/share/GeoIP (change to your folder)
    wget -N -q http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz
    gunzip -c GeoLite2-City.mmdb.gz > GeoLite2-City.mmdb

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-12-03