https://github.com/g4code/geoip
geoip php library
https://github.com/g4code/geoip
Last synced: about 1 month ago
JSON representation
geoip php library
- Host: GitHub
- URL: https://github.com/g4code/geoip
- Owner: g4code
- License: mit
- Created: 2014-11-25T13:00:26.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2023-11-13T07:58:30.000Z (over 2 years ago)
- Last Synced: 2025-10-26T21:22:46.424Z (4 months ago)
- Language: PHP
- Size: 34.2 KB
- Stars: 2
- Watchers: 12
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
geoip
======
> geoip - [php](http://php.net) library
## Install
Via Composer
```sh
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
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();
```
[geoip_record_by_name](http://php.net/manual/en/function.geoip-record-by-name.php)
## Development
### Install dependencies
$ make install
### Run tests
$ make test
## License
(The MIT License)
see LICENSE file for details...