geoip Net_GeoIP port for Yii - Get a geographical location given an IP address

  1. Documentation
  2. Change Log

This extension is a port of the Net_GeoIP PEAR package for Yii to get a geographical location given an IP address.

Made some adjustments to make it independent of the PEAR package. Basically it's just a proxy module that uses the library developed ported by Hans Lellelid in the PEAR package.



  • Yii 1.0 or above (tested with Yii 1.1.3 but should work with previous versions)
  • Extract the release file under protected/extensions
  • Change main.php configuration file
'components' => array(
      'geoip' => array(
          'class' => 'application.extensions.geoip.CGeoIP',
          // specify filename location for the corresponding database
          'filename' => 'C:\path\to\GeoIP\GeoLiteCity.dat',
          // Choose MEMORY_CACHE or STANDARD mode
          'mode' => 'STANDARD',

See the following code example:

$location = Yii::app()->geoip->lookupLocation();
  // with IP in
  $location = Yii::app()->geoip->lookupLocation('');
  $countryCode = Yii::app()->geoip->lookupCountryCode();
  $countryName = Yii::app()->geoip->lookupCountryName();
  $org = Yii::app()->geoip->lookupOrg();
  $regionCode = Yii::app()->geoip->lookupRegion();

  // Location attributes:


Methods lookupOrg and lookupRegion require specific databases (only paid versions available from MaxMind).

Change Log

June 1, 2013
  • Fix usage of non-static method in static context
    July 21, 2010
  • Initial release.
14 0
3 533 downloads
Yii Version: 1.1
License: LGPL-3.0
Category: Networking
Developed by: Dinis
Created on: Jul 21, 2010
Last updated: 10 years ago


show all

Related Extensions