During the past few weeks I have been working on a brand new PHP extension to provide an easy object oriented interface for the GeoIP library from MaxMind. The original module (that I did not write) had two main issues. First the directory to find the databases could not be changed except in PHP.INI before PHP loads (so not even ini_set would work). Second was that it was old school and not object oriented. Another issue (so that really makes three) is that it will throw E_WARNINGS for dumb things like records not being found. If there is no record found when you ask for it I would much rather just be handed a FALSE.
[update 2011/10/26] Official GeoIPo manual/documentation is here.
This new one is nearly complete, but I am still waiting to be accepted into PECL. However it works and I have the source available for use on GitHub. Here is a little how-to on how to set up the GeoIP database and use this module.
Why use GeoIP?
- Perhaps your project has support for English, German, and Polish languages. With GeoIP you can try to guess what country your visitor is from and if they are from a country with a language you support you can set that language default for the user. Things like that go very far towards user experience.
- If you have a website, I doubt many people can honestly tell me they are not curious what country their visitors are from. GeoIP is an important part of determining your reader demographics. You know all those maps that show dots about where visitors are from? You need GeoIP info to do that.
- And the bane of all internet users – lets say you are the owner of YouTube/Spotify/iTunes and you need to prevent a certain country from viewing/watching/listening to specific content because of license restrictions. You are going to piss people off, but I guess for legal reasons it just needs to be done.
These are only three of the many valid reasons you might need GeoIP information. Over here I have a page demoing the readout of the server and visitor’s GeoIP info, with a link to the visible source at the bottom.



