Class Reader
Instances of this class provide a reader for the GeoIP2 database format.
IP addresses can be looked up using the database specific methods.
Usage
The basic API for this class is the same for every database. First, you
create a reader object, specifying a file name. You then call the method
corresponding to the specific database, passing it the IP address you want
to look up.
If the request succeeds, the method call will return a model class for
the method you called. This model in turn contains multiple record classes,
each of which represents part of the data returned by the database. If
the database does not contain the requested information, the attributes
on the record class will have a null
value.
If the address is not in the database, an
GeoIp2\Exception\AddressNotFoundException
exception will be
thrown. If an invalid IP address is passed to one of the methods, a
SPL InvalidArgumentException
will be thrown. If the database is
corrupt or invalid, a \MaxMind\Db\Reader\InvalidDatabaseException
will be thrown.
-
GeoIp2\Database\Reader
implements
GeoIp2\ProviderInterface
Methods summary
public
|
#
__construct( string $filename, array $locales = array('en') )
Constructor.
Parameters
- $filename
- The path to the GeoIP2 database file.
- $locales
- <p>List of locale codes to use in name property
from most preferred to least preferred.</p>
Throws
MaxMind\Db\Reader\InvalidDatabaseException if the database
is corrupt or invalid
|
public
GeoIp2\Model\City
|
#
city( string $ipAddress )
This method returns a GeoIP2 City model.
This method returns a GeoIP2 City model.
Parameters
- $ipAddress
- IPv4 or IPv6 address as a string.
Returns
Throws
Implementation of
|
public
GeoIp2\Model\Country
|
#
country( string $ipAddress )
This method returns a GeoIP2 Country model.
This method returns a GeoIP2 Country model.
Parameters
- $ipAddress
- IPv4 or IPv6 address as a string.
Returns
Throws
Implementation of
|
public
GeoIp2\Model\AnonymousIp
|
#
anonymousIp( string $ipAddress )
This method returns a GeoIP2 Anonymous IP model.
This method returns a GeoIP2 Anonymous IP model.
Parameters
- $ipAddress
- IPv4 or IPv6 address as a string.
Returns
Throws
|
public
GeoIp2\Model\ConnectionType
|
#
connectionType( string $ipAddress )
This method returns a GeoIP2 Connection Type model.
This method returns a GeoIP2 Connection Type model.
Parameters
- $ipAddress
- IPv4 or IPv6 address as a string.
Returns
Throws
|
public
GeoIp2\Model\Domain
|
#
domain( string $ipAddress )
This method returns a GeoIP2 Domain model.
This method returns a GeoIP2 Domain model.
Parameters
- $ipAddress
- IPv4 or IPv6 address as a string.
Returns
Throws
|
public
GeoIp2\Model\Isp
|
#
isp( string $ipAddress )
This method returns a GeoIP2 ISP model.
This method returns a GeoIP2 ISP model.
Parameters
- $ipAddress
- IPv4 or IPv6 address as a string.
Returns
Throws
|
public
MaxMind\Db\Reader\Metadata
|
#
metadata( )
Returns
MaxMind\Db\Reader\Metadata object for the database.
Throws
|
public
|
#
close( )
Closes the GeoIP2 database and returns the resources to the system.
Closes the GeoIP2 database and returns the resources to the system.
|