GeoIP and IP to Country in PHP

David Tkachuk picture David Tkachuk · Nov 16, 2012 · Viewed 32.3k times · Source

Possible Duplicate:
How to get the page visitors Country with PHP?

I've been searching everywhere, and I can't seem to find anything. I need a free PHP GeoIP/Ip to country.

All I can find is that it gives me the country and small form of the country. I also would like to have information of possible street or coords, city, and maybe host information?

I need this because I am creating a PHP CMS (for myself and clients) and I want to track ips.

I don't really want an API, I want it like a database. Any ideas ?

Answer

Anthony Hatzopoulos picture Anthony Hatzopoulos · Nov 16, 2012

MaxMind GeoLite database: http://dev.maxmind.com/geoip/geolite OR pay for the full version: http://www.maxmind.com/en/geolocation_landing

They also have php libraries to go with it: http://dev.maxmind.com/geoip/downloadable

As for PHP, checkout GeoIP library and Example geoip_record_by_name()

For a database, you could make your own database overtime... and fill it with cached collected data but I doubt that would be as accurate as MaxMind's data.

There are many other methods you could use and couple them with a custom database or even combine it with the GeoLite db: geoplugin, ipinfodb