PHPackages                             midnite81/geolocation - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. midnite81/geolocation

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

midnite81/geolocation
=====================

A laravel package which wraps the IP Info DB and IP2Location Services

v4.0.0(3y ago)3624.1k↓29.7%11[1 issues](https://github.com/midnite81/geolocation/issues)MITPHPPHP &gt;=8.1

Since Oct 15Pushed 3y ago2 watchersCompare

[ Source](https://github.com/midnite81/geolocation)[ Packagist](https://packagist.org/packages/midnite81/geolocation)[ RSS](/packages/midnite81-geolocation/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (11)Versions (18)Used By (0)

Geolocation [![Latest Stable Version](https://camo.githubusercontent.com/d3f1311cc085823407171ce3a7b2585aad44d0f7d90670fda96863a0102bd741/68747470733a2f2f706f7365722e707567782e6f72672f6d69646e69746538312f67656f6c6f636174696f6e2f76657273696f6e)](https://packagist.org/packages/midnite81/geolocation) [![Total Downloads](https://camo.githubusercontent.com/85f5ae3e198e4951ba7b2467a53b0878e938e7eb7f8877ec6f59dac9b604b8f7/68747470733a2f2f706f7365722e707567782e6f72672f6d69646e69746538312f67656f6c6f636174696f6e2f646f776e6c6f616473)](https://packagist.org/packages/midnite81/geolocation) [![Latest Unstable Version](https://camo.githubusercontent.com/2045b43ff8e803f9921460cf73fd53c5f912c2dcd2408f05a9e07da1714a8b1a/68747470733a2f2f706f7365722e707567782e6f72672f6d69646e69746538312f67656f6c6f636174696f6e2f762f756e737461626c65)](https://packagist.org/packages/midnite81/geolocation) [![License](https://camo.githubusercontent.com/780656f913a42faa842a20dabde6d6c0c8a97b936348f4cef6cabb49e4f618c2/68747470733a2f2f706f7365722e707567782e6f72672f6d69646e69746538312f67656f6c6f636174696f6e2f6c6963656e73652e737667)](https://packagist.org/packages/midnite81/geolocation) [![Build](https://camo.githubusercontent.com/d1354f1b94153a9a8e4f1099bda557a456f176abff08284dbd5179960014c78d/68747470733a2f2f7472617669732d63692e6f72672f6d69646e69746538312f67656f6c6f636174696f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/midnite81/geolocation) [![Coverage Status](https://camo.githubusercontent.com/1a6519fd387a696c549c0620422959026d63cb09c1785b403b7bf4c13d0abbaa/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6d69646e69746538312f67656f6c6f636174696f6e2f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/midnite81/geolocation?branch=master)
=========================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#geolocation------)

A IP Info DB integration for Laravel

Versioning
==========

[](#versioning)

VersionBranchPHPLaravelNotes^4.0master/v4&gt;=8.1&gt;=8Update to include wrap Ip2Location in addition to IpInfoDb, moved to php 8.1^3.0v3&gt;=7.4&gt;=6Facade has been removed and guzzle dependency has been updated to version 7^2.0v2&gt;=5.6&gt;=5Corrects issues with composer 2.0^1.0v1&gt;=5.6&gt;=5First release - not compatible with composer 2.0Upgrading to v4.0
=================

[](#upgrading-to-v40)

Please note:

- version 4 brings in the ability to wrap both the IpInfoDb service (as was available in previous versions) and the Ip2Location service. IpInfoDb are not accepting new registrations and are asking users to register at Ip2Location instead.
- version 4 minimum requirements are php 8.1 to make use of the additional features php 8.1 brings, such as enums and better type safety.
- version 4 has an updated config file. If you are upgrading, I would suggest checking out the [config file](/config/geolocation.php) and updating your local instance of it.
- a change has been made to the caching from minutes to seconds.

Installation
============

[](#installation)

If installing on anything below PHP 8.1, please checkout the v2 or v3 branch and follow the instructions on the readme for that branch. Please note ip2location is not supported on previous versions of this package

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

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

```
"midnite81/geolocation": "^4.0"

```

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

Laravel Integration
-------------------

[](#laravel-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' => [
  Midnite81\GeoLocation\GeoLocationServiceProvider::class
];

```

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

Configuration File
==================

[](#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.

Env
===

[](#env)

You will need to add the following to your `.env` file and update these with your own settings. Please note you will only need to fill in the api key for the service you are using.

```
GEOLOCATION_IPINFODB_API_KEY=
GEOLOCATION_IP2LOCATION_API_KEY=
GEOLOCATION_CACHE=
```

Get your GeoLocation API Key
============================

[](#get-your-geolocation-api-key)

Before using this package you'll need to obtain an API Key from either [IpInfoDb](http://ipinfodb.com/register)which is no longer accepting new registrations or [Ip2Location](https://www.ip2location.io/sign-up).

Once you have signed up you will need to add your api key to the relevant `.env` key; `GEOLOCATION_IPINFODB_API_KEY` for IpInfoDb or `GEOLOCATION_IP2LOCATION_API_KEY` for Ip2Location.

Caching
=======

[](#caching)

This package allows you to cache responses, however it is your responsibility to ensure you're not breaking any terms and conditions of use.

Rate Limiting
=============

[](#rate-limiting)

This package does not set any rate limiting internally. You should ensure that your application adheres to any rate limiting set by your chosen provider.

Example Usage and Available Methods and Properties
==================================================

[](#example-usage-and-available-methods-and-properties)

- [IpInfoDb example usage and available methods](/readme_ipinfodb.md)
- [Ip2Location example usage and available methods](/readme_ip2location.md)

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity40

Moderate usage in the ecosystem

Community16

Small or concentrated contributor base

Maturity80

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 92.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~142 days

Recently: every ~211 days

Total

16

Last Release

1370d ago

Major Versions

v1.0.5 → v2.0.02020-04-26

v1.0.7 → v2.x-dev2020-04-26

v1.x-dev → v3.0.02020-10-29

v3.x-dev → v4.x-dev2022-08-17

PHP version history (3 changes)v1.0.0PHP &gt;=5.5.9

v3.0.0PHP &gt;=7.4

v4.x-devPHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/edf6a9952472e4cdd5a0e12ad3b9bd15b801c08a5cd56f33f6c8495aef4968ed?d=identicon)[midnite81](/maintainers/midnite81)

---

Top Contributors

[![midnite81](https://avatars.githubusercontent.com/u/254850?v=4)](https://github.com/midnite81 "midnite81 (50 commits)")[![evertramos](https://avatars.githubusercontent.com/u/905951?v=4)](https://github.com/evertramos "evertramos (2 commits)")[![LasseRafn](https://avatars.githubusercontent.com/u/2689341?v=4)](https://github.com/LasseRafn "LasseRafn (1 commits)")[![mnabialek](https://avatars.githubusercontent.com/u/7656807?v=4)](https://github.com/mnabialek "mnabialek (1 commits)")

---

Tags

geolocationgeolocation-apiip2locationipinfodblaravellaravel-packagelaravelgeolocationsmslocationip2locationipinfodbIP Info DB

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/midnite81-geolocation/health.svg)

```
[![Health](https://phpackages.com/badges/midnite81-geolocation/health.svg)](https://phpackages.com/packages/midnite81-geolocation)
```

###  Alternatives

[torann/geoip

Support for multiple Geographical Location services.

2.2k14.2M76](/packages/torann-geoip)[stevebauman/location

Retrieve a user's location by their IP Address

1.3k7.6M65](/packages/stevebauman-location)[spatie/geocoder

Geocoding addresses to coordinates

8404.8M15](/packages/spatie-geocoder)[ip2location/ip2location-laravel

Lookup for visitor's IP information, such as country, region, city, coordinates, zip code, time zone, ISP, domain name, connection type, area code, weather, MCC, MNC, mobile brand name, elevation and usage type.

83516.9k1](/packages/ip2location-ip2location-laravel)[adrianorosa/laravel-geolocation

Laravel Geo Location package to get details for a given IP Address

6593.3k1](/packages/adrianorosa-laravel-geolocation)[interaction-design-foundation/laravel-geoip

Support for multiple Geographical Location services.

17221.0k3](/packages/interaction-design-foundation-laravel-geoip)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
