class Reader (View source)

Instances of this class provide a reader for the MaxMind DB format. IP addresses can be looked up using the get method.

Methods

__construct(string $database)

Constructs a Reader for the MaxMind DB format. The file passed to it must be a valid MaxMind DB file such as a GeoIp2 database file.

mixed
get(string $ipAddress)

Retrieves the record for the IP address.

array
getWithPrefixLen(string $ipAddress)

Retrieves the record for the IP address and its associated network prefix length.

metadata()

No description

void
close()

Closes the MaxMind DB and returns resources to the system.

Details

__construct(string $database)

Constructs a Reader for the MaxMind DB format. The file passed to it must be a valid MaxMind DB file such as a GeoIp2 database file.

Parameters

string $database

the MaxMind DB file to use

Exceptions

InvalidArgumentException
InvalidDatabaseException

mixed get(string $ipAddress)

Retrieves the record for the IP address.

Parameters

string $ipAddress

the IP address to look up

Return Value

mixed

the record for the IP address

Exceptions

InvalidArgumentException
InvalidDatabaseException
BadMethodCallException

array getWithPrefixLen(string $ipAddress)

Retrieves the record for the IP address and its associated network prefix length.

Parameters

string $ipAddress

the IP address to look up

Return Value

array

Exceptions

InvalidArgumentException
InvalidDatabaseException
BadMethodCallException

Metadata metadata()

No description

Return Value

Metadata

object for the database

Exceptions

BadMethodCallException
InvalidArgumentException

void close()

Closes the MaxMind DB and returns resources to the system.

Return Value

void

Exceptions

Exception