Giter Club home page Giter Club logo

geoip-module's Introduction

#README

##PROLOGUE

My project demands on detecting and storing accessed IP data.
So I found geoip/geoip package. And everything else is to store it.
The best way is serialize or create record in DB. The second way with Doctrine 2 is very slow as appeared in my experience.

###Why not geoip2/geoip2 or MaxMind-DB-Reader-php with .mmdb Really? It contains wished class Record for serialization already but: As experiment showed:

  • Record Object has all Country name translations what I do with internalization library.
  • Record Object is too huge so Its serialization take too long string.
  • It much SLOWLY then geoip1 with sqlite db. In 2-3 times. (Tested on about 2500 IPs)

So I decided to create alternate Record object that will utilize fast geoip sqlite db and fit to
now-day Object using. It easily can be extended to Doctrine Entity or Document.

##How to install Install it by composer.

{
    "require": {
        "vnagara/geoip-module": "1.*"
    }
}

Download geoip sql DB to data/GeoLiteCity.dat or set another path in configuration file.
On linux with wget you can use this command (inside project root):

    wget -O - http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz | gzip -dc > data/GeoLiteCity.dat

In application.config.php enable GeoipModule module.

##New methods:

  1. In view helpers: geoipRecord($ipAddress) will return GeoipRecord.
  2. There is new service geoip. So in controller it is accessible by:
    /** @var \GeoipModule\Service\Geoip */
    $geoip = $this->getServiceLocator()->get('geoip');

    /** @var \GeoipModule\Object\Record */
    $recordOfSomeIpAddress = $geoip->find('184.154.227.14');
    $city = $recordOfSomeIpAddress->getCity();  // Chicago

    // The same:
    $recordOfSomeIpAddress = $geoip->lookup('184.154.227.14');

    // To use ip from $_SERVER['REMOTE_ADDR']
    $record = $geoip->find();

##Doctrine ORM Template of Entity with annotation lays by path: src/GeoipModule/Entity/Record.php

geoip-module's People

Contributors

vnagara avatar

Stargazers

Alexander Tukai avatar Yannick L avatar

Watchers

James Cloos avatar  avatar

Forkers

libracms

geoip-module's Issues

Rename to zf2-geoip

This looks to be essentially a "glue package", which takes geoip and integrates it nicely into ZF2.

A more standard naming format for glue packages is zf2-geoip, this is the same in any language or framework. rails-mustache for example.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.