PHPackages                             maxmind-db/reader - 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. [Database &amp; ORM](/categories/database)
4. /
5. maxmind-db/reader

ActiveLibrary[Database &amp; ORM](/categories/database)

maxmind-db/reader
=================

MaxMind DB Reader API

v1.13.1(5mo ago)69699.2M—0.6%82[5 issues](https://github.com/maxmind/MaxMind-DB-Reader-php/issues)20Apache-2.0PHPPHP &gt;=7.2CI passing

Since Jul 16Pushed 3w ago38 watchersCompare

[ Source](https://github.com/maxmind/MaxMind-DB-Reader-php)[ Packagist](https://packagist.org/packages/maxmind-db/reader)[ Docs](https://github.com/maxmind/MaxMind-DB-Reader-php)[ RSS](/packages/maxmind-db-reader/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (38)Used By (20)

MaxMind DB Reader PHP API
=========================

[](#maxmind-db-reader-php-api)

Description
-----------

[](#description)

This is the PHP API for reading MaxMind DB files. MaxMind DB is a binary file format that stores data indexed by IP address subnets (IPv4 or IPv6).

Installation
------------

[](#installation)

### C Extension (Recommended for Performance)

[](#c-extension-recommended-for-performance)

For significantly faster IP lookups, we recommend installing the C extension via [PIE](https://github.com/php/pie):

```
pie install maxmind-db/reader-ext
```

The C extension requires the [libmaxminddb](https://github.com/maxmind/libmaxminddb)C library. See the [installation instructions](https://github.com/maxmind/MaxMind-DB-Reader-php-ext#prerequisites)for your platform.

### Pure PHP (No Compilation Required)

[](#pure-php-no-compilation-required)

If you prefer not to compile a C extension or need maximum portability, you can install the pure PHP implementation with [Composer](https://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 maxmind-db/reader:^1.13.1

```

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';
```

Installation (Standalone)
-------------------------

[](#installation-standalone)

If you don't want to use Composer for some reason, a custom `autoload.php` is provided for you in the project root. To use the library, simply include that file,

```
require('/path/to/MaxMind-DB-Reader-php/autoload.php');
```

and then instantiate the reader class normally:

```
use MaxMind\Db\Reader;
$reader = new Reader('example.mmdb');
```

Installation (RPM)
------------------

[](#installation-rpm)

RPMs are available in the [official Fedora repository](https://apps.fedoraproject.org/packages/php-maxminddb).

To install on Fedora, run:

```
dnf install php-maxminddb
```

To install on CentOS or RHEL 7, first [enable the EPEL repository](https://fedoraproject.org/wiki/EPEL)and then run:

```
yum install php-maxminddb
```

Please note that these packages are *not* maintained by MaxMind.

Usage
-----

[](#usage)

Example
-------

[](#example)

```
