Supports Maxmind GeoIP services
13
0
2
Package Data
Maintainer Username: riteshptl21
Maintainer Contact: riteshptl21@gmail.com (Ritesh Patel)
Package Create Date: 2016-02-17
Package Last Update: 2022-05-30
Home Page:
Language: PHP
License: BSD 2-Clause
Last Refreshed: 2024-11-18 03:04:28
Package Statistics
Total Downloads: 13
Monthly Downloads: 1
Daily Downloads: 0
Total Stars: 0
Total Watchers: 2
Total Forks: 0
Total Open Issues: 0

Maxmind GeoIP2 API For Laravel 4.2

Description

Latest Stable Version Total Downloads

Geoip is a Laravel package that aims to seamlessly integrate MaxMind functionality for determine the geographical location of IP addresses in laravel.

Installation

Add geoip to your composer.json file:

"riteshptl21/geoip": "0.1.*"

You'll then need to run composer install to download it and have the autoloader updated.

Add the service provider to your Laravel application config:

'Riteshptl21\Geoip\GeoipServiceProvider'

Create configuration file using artisan

$ php artisan config:publish riteshptl21/geoip

Once you fire this command you see config file at app/config/packages/riteshptl21/geoip/config.php and set config at there.

Usage

Get the location data for a website visitor:

$location = Geoip::getLocation();

When an IP is not given the $_SERVER["REMOTE_ADDR"] is used.

Getting the location data for a given IP:

$location = Geoip::getLocation( '2.24.234.19' );

Note

In the case that a location is not found the fallback location will be returned with the default_location parameter that you set in config.By default default_location is like as under:

array (
    "ip"            => "127.0.0.0",
    "isoCode"       => "IN",
    "country"       => "India",
    "city"          => "Ahmedabad",
    "state_code"         => "GJ",
    "postal_code"   => "261201",
    "lat"           => 23.0333,
    "lon"           => 72.6167,
    "timezone"      => "Asia/Kolkata",
    "continent"     => "AS",
    "default"       => true
)