PHPackages                             thirtybees/geoip - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. thirtybees/geoip

AbandonedLibrary[Utility &amp; Helpers](/categories/utility)

thirtybees/geoip
================

MaxMind GeoIP PHP API

010.4k2PHP

Pushed 8y ago2 watchersCompare

[ Source](https://github.com/thirtybees/geoip-api-php)[ Packagist](https://packagist.org/packages/thirtybees/geoip)[ RSS](/packages/thirtybees-geoip/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (1)DependenciesVersionsUsed By (0)

MaxMind GeoIP Legacy PHP API
============================

[](#maxmind-geoip-legacy-php-api)

Important Note
--------------

[](#important-note)

This API is for the GeoIP Legacy format (dat). To read the MaxMind DB format (mmdb) used by GeoIP2, please see [our GeoIP2 PHP API](https://github.com/maxmind/GeoIP2-php).

This package has been forked in order to make it work with the `geoip` PHP extension. In case the `geoip` extension is loaded and active this library will not become active, thus making it safe to include with frameworks that have to support a multitude of platforms.

Requirements
------------

[](#requirements)

This module has no external dependencies. You only need a MaxMind GeoIP database. To download a free GeoLite Legacy Country database, please see our [GeoLite Legacy page](http://dev.maxmind.com/geoip/legacy/geolite).

Install via Composer
--------------------

[](#install-via-composer)

We recommend installing this package with [Composer](http://getcomposer.org/).

### Download Composer

[](#download-composer)

To download Composer, run in the root directory of your project:

```
curl -sS https://getcomposer.org/installer | php
```

You should now have the file `composer.phar` in your project directory.

### Install Dependencies

[](#install-dependencies)

Run in your project root:

```
php composer.phar require geoip/geoip:~1.16

```

You should now have the files `composer.json` and `composer.lock` as well as the directory `vendor` in your project directory. If you use a version control system, `composer.json` should be added to it.

### Require Autoloader

[](#require-autoloader)

After installing the dependencies, you need to require the Composer autoloader from your code:

```
require 'vendor/autoload.php';
```

Install without Composer
------------------------

[](#install-without-composer)

Place the 'geoip.inc' file in the `include_path` as specified in your `php.ini` file or place it in the same directory as your PHP scripts.

IP Geolocation Usage
--------------------

[](#ip-geolocation-usage)

IP geolocation is inherently imprecise. Locations are often near the center of the population. Any location provided by a GeoIP database should not be used to identify a particular address or household.

Usage
-----

[](#usage)

Gets country name by hostname :

```
