geoip2/geoip2
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
maxmind-db/reader | v1.11.1 | 30.38 kB | Apache-2.0 | prod |
The package geoip2/geoip2, developed by MaxMind, provides a PHP API that enables integration with the GeoIP2 and GeoLite2 web services and databases. This advanced geo-targeting technology allows developers to determine the geographical location of a specific IP address and much other related information.
Utilizing geoip2/geoip2 in your project involves installing it via Composer, a standard package manager for PHP. To do so, navigate to the root directory of your project and run the command php composer.phar require geoip2/geoip2:~2.0
. After running this command, the dependent files (composer.json
and composer.lock
) and vendor
directory should be created in your project directory.
To employ this package, include the auto-loader provided by Composer in your PHP code using require 'vendor/autoload.php';
. Now, you are ready to create a Reader
or Client
object and call the corresponding method for the web service or database you want to use.
For example, to find information about a specific IP address using the city database, you can use the following code:
require_once 'vendor/autoload.php';
use GeoIp2\Database\Reader;
$reader = new Reader('/path/to/GeoIP2-City.mmdb');
$record = $reader->city('128.101.101.101');
Multiple examples on how to utilize geoip2/geoip2 in different situations are provided in the README of the package.
The documentation for geoip2/geoip2 can be found at two locations provided in the README. The GeoIP2 and GeoLite2 web services documentation is available here and the databases documentation is accessible here. More detailed information is found on the API documentation in the PHP manual. The README also provides a comprehensive guide on using the package, including different installation methods, examples on how to use the package for different situations, database updates, data issues, and other support details.