Simple Geo Location Information using IP Address

1.5.2 2016-04-12 03:58 UTC

This package is not auto-updated.

Last update: 2024-05-10 10:48:00 UTC


README

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

Geo Ip took all available information from an Ip Address using data from GeoPlugin.

Work with Laravel 5.5 (tested).

Geo IP use Geoplugin to gather information.

Install

You can install GeoIp via composer.

$ composer require sabartampubolon/geoip

Requires Laravel Framework 5.5 and PHP 5.5.9 or newer. Visit GeoIp repository at Packagist.

Usage

To use GeoIp, you can simply inject GeoIp instance into Laravel controller

<?php

use Sabartampubolon\Geoip\Geoip;

// Use destination Ip
$geoip = new Geoip('8.8.8.8');
 
// Or just let it blank to automatic use client ip address
$geoip = new Geoip();
 
  
// Gather information from ip address
$info = $geoip->getInfo();

The code above will give a result in json format like this (use IP Address 8.8.8.8):

{"ip_address":"8.8.8.8","country_code":"US","country_name":"United States","city":"Mountain View","region":"CA","region_name":"California","region_code":"CA","latitude":"37.3845","longitude":"-122.0881"}

Credits

License

The MIT License (MIT). Please see License File for more information.