PHPackages                             geoip/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. geoip/geoip

Abandoned → [geoip2/geoip2](/?search=geoip2%2Fgeoip2)ArchivedLibrary[Utility &amp; Helpers](/categories/utility)

geoip/geoip
===========

MaxMind GeoIP PHP API

v1.17(10y ago)5283.0M—4.9%32512LGPL 2.1+PHP

Since May 27Pushed 5y ago83 watchersCompare

[ Source](https://github.com/maxmind/geoip-api-php)[ Packagist](https://packagist.org/packages/geoip/geoip)[ Docs](http://dev.maxmind.com/geoip/legacy/downloadable)[ RSS](/packages/geoip-geoip/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (8)Dependencies (2)Versions (6)Used By (12)

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

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

End of Life
-----------

[](#end-of-life)

MaxMind will be retiring the GeoIP Legacy databases at the end of May 2022. Until then, this library will only receive critical security and bug fixes. Support for this library will end completely with the last release of the legacy GeoIP databases.

We recommend that you upgrade to our GeoIP2 databases. You can read these from PHP with [our GeoIP2 PHP API](https://github.com/maxmind/GeoIP2-php).

See [our blog post](https://blog.maxmind.com/2020/06/01/retirement-of-geoip-legacy-downloadable-databases-in-may-2022/)for more information.

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

[](#requirements)

This module has no external dependencies. You only need a MaxMind GeoIP database.

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 :

```
