Skip to content

fadsel/ci-geo-ip

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

GeoIP2 Codeigniter Library

Codeigniter 3.x Library for accessing all APIs from GeoIP2 webservice client and database reader

Description

This package provides an API for the GeoIP2 web services and databases. The API also works with the free GeoLite2 databases.

How to install

1.Download this archieve phar archive containing all of the dependencies for GeoIP2 from their release page the releases page.

Place it inside application/vendor/geo/ folder or any other folder you wish Make sure you update your database path in the library if you decide to place it else where

2.Download the City Database for free from here GeoLite2 databases.

How to Use

You can let the library guess your location

<?php

class YourAwesomeController extends CI_Controller{
    public function get_geo(){
        
        $this->load->library("CI_GeoIp2");
        $reader = new CI_GeoIp2();
        $reader->setIp();
        
        print_r($reader->getCountry()); // Prints out "Tanzania" or any other country you are in
        

    }
}

or you can pass in any IP

 
        $this->load->library("CI_GeoIp2");
        $reader = new CI_GeoIp2();
        $reader->setIp("123.456.789.10");
        
        //if you want to manually extract objects
        var_dump($reader->getRawRecord()); 
 

Requirements

This code requires PHP 5.3 or greater. Older versions of PHP are not supported.


License

This software is Copyright (c) 2017 by Safi Cloud Creative Commons License
CI GEO IP2 by Safi Cloud is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
Permissions beyond the scope of this license may be available at saficloud.com/legal.

About

Codeigniter 3.x Library for accessing all APIs from GeoIP2 webservice client and database reader

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages