g4 / geoip
geoip php library
Installs: 46 750
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 14
Forks: 5
Open Issues: 1
Requires
- php: >=8.2
- ext-mbstring: *
- geoip2/geoip2: >=2.13.0
Requires (Dev)
- phpunit/phpunit: 10.*
This package is auto-updated.
Last update: 2024-12-13 10:07:44 UTC
README
geoip - php library
Install
Via Composer
composer require g4/geoip
Requirements
- PHP GeoIP extension http://php.net/manual/en/geoip.setup.php
- Maxmind GeoIP database http://dev.maxmind.com/
- Maxmind GeoIP2-City database
Installing required packages (CentOS, Redhat)
- yum install GeoIP
- yum install GeoIP-devel
- yum install geoipupdate
- pecl install geoip
Usage
<?php $geoIp = new \G4\GeoIP\GeoIP('127.0.0.1'); // "area_code" -- The PSTN area code (ex: 212) echo $geoIp->getAreaCode(); // "dma_code" -- Designated Market Area code (USA and Canada only) echo $geoIp->getDmaCode(); // "city" -- The city echo $geoIp->getCity(); // "continent_code" -- Two letter continent code echo $geoIp->getContinentCode(); // "country_code" -- Two letter country code echo $geoIp->getCountryCode(); // "country_code3" -- Three letter country code echo $geoIp->getCountryCode3(); // "country_name" -- The country name echo $geoIp->getCountryName(); // IP address echo $geoIp->getIp(); // "latitude" -- The Latitude as signed double echo $geoIp->getLatitude(); // "longitude" -- The Longitude as signed double echo $geoIp->getLongitude(); // "postal_code" -- The Postal Code, FSA or Zip Code echo $geoIp->getPostalCode(); // "region" -- The region code (ex: CA for California) echo $geoIp->getRegion();
Development
Install dependencies
$ make install
Run tests
$ make test
License
(The MIT License) see LICENSE file for details...