Download the PHP package midnite81/geolocation without Composer

On this page you can find all versions of the php package midnite81/geolocation. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

Please rate this library. Is it a good library?

All versions of geolocation with dependencies

Informations about the package geolocation

Geolocation Latest Stable Version Total Downloads Latest Unstable Version License Build Coverage Status

A IP Info DB integration for Laravel


Version Branch PHP Laravel Notes
^3.0 master >=7.4 >=6 Latest release, facade has been removed and guzzle dependency has been updated to version 7
^2.0 v2 >=5.6 >=5 Corrects issues with composer 2.0
^1.0 v1 >=5.6 >=5 First release - not compatible with composer 2.0


If installing on anything below PHP 7.4, please checkout the v2 branch and follow the instructions on the readme for that branch.

This package requires PHP 7.4+, and includes a Laravel Service Provider.

To install through composer include the package in your composer.json.

"midnite81/geolocation": "^3.0"

Run composer install or composer update to download the dependencies, or you can run composer require midnite81/geolocation.

Laravel 5 Integration

This package makes use of Laravel's auto package loader, so you shouldn't need to add this to your config/app.php file. However, if you've disabled this then you'll need to add the GeoLocation service provider to the list of service providers in app/config/app.php.

'providers' => [



Publish the config and migration files using php artisan vendor:publish --provider="Midnite81\GeoLocation\GeoLocationServiceProvider"

Configuration File

Once you have published the config files, you will find a geolocation.php file in the config folder. You should look through these settings and update these where necessary.


You will need to add the following to your .env file and update these with your own settings


Get your GeoLocation API Key

Before using this package you must get an API Key from IP Info DB. Please access and after registering and confirming your email address your api key will be show. Please copy and set to your .env file on GEOLOCATION_API_KEY option.

Example Usage

use Midnite81\GeoLocation\Contracts\Services\GeoLocationInterface;
use Illuminate\Http\Request;

public function index(GeoLocationInterface $geo, Request $request) 
    $ipLocation = $geo->getCity($request->ip());

    // if you do $geo->get($request->ip()), the default precision is now city

    // $ipLocation is an IpLocation Object

    echo $ipLocation->ipAddress; // e.g.

    echo $ipLocation->getAddressString(); // e.g. London, United Kingdom

    // the object has a toJson() and toArray() method on it 
    // so you can die and dump an array.


Methods on IpLocation

$ipLocation->getStatusCode(); // returns status code of request (e.g. 200)
$ipLocation->getStatusMessage(); // returns any status message to go with code
$ipLocation->getIpAddress(); // the geolocation IP requested
$ipLocation->getCountryCode(); // country code of the IP e.g. GB
$ipLocation->getCountryName(); // country name of the IP e.g. United Kingdom
$ipLocation->getRegionName(); // region name of the IP e.g. England
$ipLocation->getCityName(); // city name of the IP e.g. London
$ipLocation->getZipCode(); // postcode of the IP e.g. SE01 1AA
$ipLocation->getPostCode(); // postcode of the IP e.g. SE01 1AA
$ipLocation->getLatitude(); // latitude of the IP e.g. 53.4030
$ipLocation->getLongitude(); // longitude of the IP e.g. -1.201
$ipLocation->getTimeZone(); // timezone of the IP e.g. +01:00
$ipLocation->getAddressString(); // gets the city, region and country as a string
$ipLocation->toArray(); // returns object as an array
$ipLocation->toJson(); // returns object as a json object

Requires php Version >=7.4
guzzlehttp/guzzle Version ^7.0
ext-json Version *

The package midnite81/geolocation contains the following files

Loading the files please wait ....