PHPackages                             pulkitjalan/ip-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. pulkitjalan/ip-geolocation

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

pulkitjalan/ip-geolocation
==========================

IP Geolocation Wrapper with Laravel Support

9.0.0(2mo ago)89164.9k↓25.7%42[2 PRs](https://github.com/pulkitjalan/ip-geolocation/pulls)1MITPHPPHP ^8.2CI passing

Since Jan 11Pushed 2mo ago8 watchersCompare

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

READMEChangelog (10)Dependencies (12)Versions (40)Used By (1)

IP Geolocation
==============

[](#ip-geolocation)

> IP Geolocation Wrapper with Laravel Support

[![Latest Stable Version](https://camo.githubusercontent.com/c6c4861602f8832bb8f45c8d894bcade7c4c587aaa2f89a3dd7d78c5a9942065/68747470733a2f2f706f7365722e707567782e6f72672f70756c6b69746a616c616e2f69702d67656f6c6f636174696f6e2f762f737461626c653f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/pulkitjalan/ip-geolocation)[![MIT License](https://camo.githubusercontent.com/30597ff9a350144f03bffdd9183e16468e0b3ca1193e1d08591d992622738d55/687474703a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](http://www.opensource.org/licenses/MIT)[![Run Tests](https://github.com/pulkitjalan/ip-geolocation/actions/workflows/run-tests.yml/badge.svg)](https://github.com/pulkitjalan/ip-geolocation/actions/workflows/run-tests.yml)[![Coverage](https://camo.githubusercontent.com/d4079219524726a8d661190266248572c4425047305e0cfcf71354cd8cae53dd/68747470733a2f2f636f6465636f762e696f2f67682f70756c6b69746a616c616e2f69702d67656f6c6f636174696f6e2f67726170682f62616467652e7376673f746f6b656e3d64706a5a3454737a786d)](https://codecov.io/gh/pulkitjalan/ip-geolocation)[![Total Downloads](https://camo.githubusercontent.com/2eba2fe706d0af4f6011335a9cb2535efefcd54daccd091d6a3e98d378173d5d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f70756c6b69746a616c616e2f69702d67656f6c6f636174696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/pulkitjalan/ip-geolocation)

This package provides an easy way to get geolocation information from IP addresses. It supports multiple drivers including IP-API, MaxMind Database, MaxMind API, IPStack, IP2Location, and IPinfo.

Requirements
------------

[](#requirements)

- PHP &gt;= 8.2
- Laravel 11.x or 12.x on PHP 8.2+
- Laravel 13.x on PHP 8.3+

Installation
------------

[](#installation)

Install via composer:

```
composer require pulkitjalan/ip-geolocation
```

### Laravel

[](#laravel)

There is a Laravel service provider and facade available.

Add the following to the `providers` array in your `config/app.php`

```
PulkitJalan\IPGeolocation\IPGeolocationServiceProvider::class
```

Next add the following to the `aliases` array in your `config/app.php`

```
'IPGeolocation' => PulkitJalan\IPGeolocation\Facades\IPGeolocation::class
```

Next publish the config file:

```
php artisan vendor:publish --provider="PulkitJalan\IPGeolocation\IPGeolocationServiceProvider" --tag="config"
```

#### Using an older version of PHP / Laravel?

[](#using-an-older-version-of-php--laravel)

If you are on a PHP version below 8.2 or a Laravel version below 11.0, use an older version of this package.

Usage
-----

[](#usage)

The ipGeolocation class takes a config array as the first parameter or defaults to using the `ip-api` driver.

Example:

```
