Reader
in package
implements
ProviderInterface
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 exception will be thrown. If an invalid IP address is passed to one of the methods, a SPL will be thrown. If the database is corrupt or invalid, a will be thrown.
Table of Contents
Interfaces
Methods
- __construct() : mixed
- Constructor.
- anonymousIp() : AnonymousIp
- This method returns a GeoIP2 Anonymous IP model.
- asn() : Asn
- This method returns a GeoLite2 ASN model.
- city() : City
- This method returns a GeoIP2 City model.
- close() : void
- Closes the GeoIP2 database and returns the resources to the system.
- connectionType() : ConnectionType
- This method returns a GeoIP2 Connection Type model.
- country() : Country
- This method returns a GeoIP2 Country model.
- domain() : Domain
- This method returns a GeoIP2 Domain model.
- enterprise() : Enterprise
- This method returns a GeoIP2 Enterprise model.
- isp() : Isp
- This method returns a GeoIP2 ISP model.
- metadata() : Metadata
Methods
__construct()
Constructor.
public
__construct(string $filename[, array<string|int, string> $locales = ['en'] ]) : mixed
Parameters
- $filename : string
-
the path to the GeoIP2 database file
- $locales : array<string|int, string> = ['en']
-
list of locale codes to use in name property from most preferred to least preferred
Tags
anonymousIp()
This method returns a GeoIP2 Anonymous IP model.
public
anonymousIp(string $ipAddress) : AnonymousIp
Parameters
- $ipAddress : string
-
an IPv4 or IPv6 address as a string
Tags
Return values
AnonymousIpasn()
This method returns a GeoLite2 ASN model.
public
asn(string $ipAddress) : Asn
Parameters
- $ipAddress : string
-
an IPv4 or IPv6 address as a string
Tags
Return values
Asncity()
This method returns a GeoIP2 City model.
public
city(string $ipAddress) : City
Parameters
- $ipAddress : string
-
an IPv4 or IPv6 address as a string
Tags
Return values
City —a City model for the requested IP address
close()
Closes the GeoIP2 database and returns the resources to the system.
public
close() : void
connectionType()
This method returns a GeoIP2 Connection Type model.
public
connectionType(string $ipAddress) : ConnectionType
Parameters
- $ipAddress : string
-
an IPv4 or IPv6 address as a string
Tags
Return values
ConnectionTypecountry()
This method returns a GeoIP2 Country model.
public
country(string $ipAddress) : Country
Parameters
- $ipAddress : string
-
an IPv4 or IPv6 address as a string
Tags
Return values
Country —a Country model for the requested IP address
domain()
This method returns a GeoIP2 Domain model.
public
domain(string $ipAddress) : Domain
Parameters
- $ipAddress : string
-
an IPv4 or IPv6 address as a string
Tags
Return values
Domainenterprise()
This method returns a GeoIP2 Enterprise model.
public
enterprise(string $ipAddress) : Enterprise
Parameters
- $ipAddress : string
-
an IPv4 or IPv6 address as a string
Tags
Return values
Enterpriseisp()
This method returns a GeoIP2 ISP model.
public
isp(string $ipAddress) : Isp
Parameters
- $ipAddress : string
-
an IPv4 or IPv6 address as a string
Tags
Return values
Ispmetadata()
public
metadata() : Metadata
Tags
Return values
Metadata —object for the database