All Projects → bobey → geoip2-geolite2-composer

bobey / geoip2-geolite2-composer

Licence: other
This project aims to provide an easy solution to require GeoIP2 / GeoLite2 databases inside your project using composer.

Programming Languages

shell
77523 projects

Projects that are alternatives of or similar to geoip2-geolite2-composer

cygnite-application
Cygnite PHP Framework- Skeleton Application
Stars: ✭ 26 (+73.33%)
Mutual labels:  composer
routing
Aplus Framework Routing Library
Stars: ✭ 186 (+1140%)
Mutual labels:  composer
tor-ip-changer
request new identity every X seconds interval using TOR client
Stars: ✭ 233 (+1453.33%)
Mutual labels:  geoip
composer-normalize-action
+ 🎵 Provides a GitHub action for running ergebnis/composer-normalize.
Stars: ✭ 25 (+66.67%)
Mutual labels:  composer
guzzle-log-middleware
A Guzzle middleware to log request and responses automatically
Stars: ✭ 61 (+306.67%)
Mutual labels:  composer
generator-composer
🐘 Yeoman (http://yeoman.io) generator for a PHP Composer project
Stars: ✭ 16 (+6.67%)
Mutual labels:  composer
ZfSnapGeoip
Maxmind Geoip module for Zend Framework 2
Stars: ✭ 15 (+0%)
Mutual labels:  geoip
PhpBotFramework
A framework for Telegram Bot API written in PHP.
Stars: ✭ 56 (+273.33%)
Mutual labels:  composer
composer-file-loader
Tool to load namespaces and classes from composer.json file without composer
Stars: ✭ 64 (+326.67%)
Mutual labels:  composer
packagist
🐳 Dockette out-of-box Packagist (Nginx / Solr 6 / PHP 7.1+FPM)
Stars: ✭ 32 (+113.33%)
Mutual labels:  composer
pagination
Aplus Framework Pagination Library
Stars: ✭ 167 (+1013.33%)
Mutual labels:  composer
license-checker-php
CLI tool to verify used licenses in composer dependencies
Stars: ✭ 28 (+86.67%)
Mutual labels:  composer
ubiquity-devtools
Command line tools for Ubiquity framework
Stars: ✭ 12 (-20%)
Mutual labels:  composer
selene
A opinionated Wordpress base theme based on Sage.
Stars: ✭ 31 (+106.67%)
Mutual labels:  composer
gh-auto-updater
Automatic Updater with GitHub API for WordPress Plugin
Stars: ✭ 42 (+180%)
Mutual labels:  composer
GeoLite2-Country
GeoLite2-Country.mmdb.gz CDN files based on Free Open Source CDN jsDelivr!
Stars: ✭ 69 (+360%)
Mutual labels:  geoip
tug
Private Composer registry for private PHP packages on AWS Serverless
Stars: ✭ 33 (+120%)
Mutual labels:  composer
TCSTK-Angular
TIBCO Cloud™ Composer - Angular Libraries
Stars: ✭ 12 (-20%)
Mutual labels:  composer
composer-localdev-plugin
Composer Plugin for local development
Stars: ✭ 31 (+106.67%)
Mutual labels:  composer
acme2
Another PHP client for acme protocal (version 2) implementation, used for generating letsencrypt's free ssl certificates.
Stars: ✭ 45 (+200%)
Mutual labels:  composer

GeoIP2 / GeoLite2 for Composer

Description

This tiny repository aims to provide an easy solution to require GeoIP2 / GeoLite2 databases inside your project using composer. This is particularly usefull if you use it in conjunction with the GeoIP2 PHP API.

Install via composer

Just run the following command in your project root:

composer require bobey/geoip2-geolite2-composer

Use it with the GeoIP2 PHP API

composer require geoip2/geoip2:~2.0

City Example rewritten

The following example is the one provided in the GeoIP2 PHP API README rewritten to lookup the GeoLite2 database inside your vendors directory.

<?php
require_once 'vendor/autoload.php';
use GeoIp2\Database\Reader;

// This creates the Reader object, which should be reused across
// lookups.
$reader = new Reader('vendor/bobey/geoip2-geolite2-composer/GeoIP2/GeoLite2-City.mmdb');

// Replace "city" with the appropriate method for your database, e.g.,
// "country".
$record = $reader->city('128.101.101.101');

print($record->country->isoCode . "\n"); // 'US'
print($record->country->name . "\n"); // 'United States'
print($record->country->names['zh-CN'] . "\n"); // '美国'

print($record->mostSpecificSubdivision->name . "\n"); // 'Minnesota'
print($record->mostSpecificSubdivision->isoCode . "\n"); // 'MN'

print($record->city->name . "\n"); // 'Minneapolis'

print($record->postal->code . "\n"); // '55455'

print($record->location->latitude . "\n"); // 44.9733
print($record->location->longitude . "\n"); // -93.2323

Update

GeoLite2 databases are updated on the first Tuesday of each month. I will try to update and tag a new version of this repository as often as possible. In the meantime, if you want to update the databases yourself, just fork the repository, execute the update script by running the following command:

./scripts/update.sh

Then, just make a pull request!

License

The GeoLite2 databases are distributed under the Creative Commons Attribution-ShareAlike 3.0 Unported License. The attribution requirement may be met by including the following in all advertising and documentation mentioning features of or use of this database:

This product includes GeoLite2 data created by MaxMind, available from http://www.maxmind.com.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].