PHPackages                             devrabiul/laravel-geo-genius - 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. [Localization &amp; i18n](/categories/localization)
4. /
5. devrabiul/laravel-geo-genius

ActiveLibrary[Localization &amp; i18n](/categories/localization)

devrabiul/laravel-geo-genius
============================

Laravel GeoGenius — A powerful, intelligent toolkit for geo-location, timezone, and locale-based features in Laravel applications.

v1.5(5mo ago)1757.6k↓13.8%11MITPHPPHP ^8.0

Since Sep 13Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/devrabiul/laravel-geo-genius)[ Packagist](https://packagist.org/packages/devrabiul/laravel-geo-genius)[ Docs](https://github.com/devrabiul/laravel-geo-genius)[ GitHub Sponsors](https://github.com/devrabiul)[ Fund](https://ko-fi.com/devrabiul)[ RSS](/packages/devrabiul-laravel-geo-genius/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)DependenciesVersions (7)Used By (0)

📦 Laravel GeoGenius — Timezone, Geolocation, Multilingual Toolkit &amp; Country Picker for Laravel
==================================================================================================

[](#-laravel-geogenius--timezone-geolocation-multilingual-toolkit--country-picker-for-laravel)

**Laravel GeoGenius** is a lightweight, flexible package for Laravel applications that handles:

- 🌐 **Geolocation** — Detect user location via IP
- 🕒 **Timezone Management** — Detect and convert user timezones automatically
- 🏷️ **Multilingual &amp; Translation Support** — Auto-detect locale, translate messages, and even convert numbers
- 📱 **Country Picker &amp; Phone Validation** — Auto-detect default country, show a dropdown of all countries, format and validate numbers automatically

It automatically retrieves detailed IP-based location data, detects the user’s timezone, sets the correct locale, and even initialises a fully-functional phone input field with country picker and validation — all seamlessly integrated into your app.

✅ Fully compatible with **Livewire**, works via **cookies or headers**, and enables a truly **global-ready Laravel application**.

[![Latest Stable Version](https://camo.githubusercontent.com/36f158289f4ac2ce936ff465d9b8265613254de76bd5381227c59b3418ffd62f/68747470733a2f2f706f7365722e707567782e6f72672f64657672616269756c2f6c61726176656c2d67656f2d67656e6975732f762f737461626c65)](https://packagist.org/packages/devrabiul/laravel-geo-genius)[![Total Downloads](https://camo.githubusercontent.com/a466f6eebfa5cb42063898aea72ec936d2183e14759c2f39ca7a2d1c24813695/68747470733a2f2f706f7365722e707567782e6f72672f64657672616269756c2f6c61726176656c2d67656f2d67656e6975732f646f776e6c6f616473)](https://packagist.org/packages/devrabiul/laravel-geo-genius)[![Monthly Downloads](https://camo.githubusercontent.com/0ad13423be190d603b08a1d6084f3132b6df664bd07b27d9efb5f6a7493ecf11/68747470733a2f2f706f7365722e707567782e6f72672f64657672616269756c2f6c61726176656c2d67656f2d67656e6975732f642f6d6f6e74686c79)](https://packagist.org/packages/devrabiul/laravel-geo-genius)[![GitHub license](https://camo.githubusercontent.com/d209eec63eac9f6a5e0c87121e285c1374181d0174a1b2605ae3ff2ba5b3dc9b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f64657672616269756c2f6c61726176656c2d67656f2d67656e697573)](https://camo.githubusercontent.com/d209eec63eac9f6a5e0c87121e285c1374181d0174a1b2605ae3ff2ba5b3dc9b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f64657672616269756c2f6c61726176656c2d67656f2d67656e697573)[![Buy us a tree](https://camo.githubusercontent.com/130148911f548b001b2ac68a32c0a06559977ca60ada3bf480c72ae4ea093175/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f54726565776172652d2546302539462538432542332d6c69676874677265656e)](https://plant.treeware.earth/devrabiul/laravel-geo-genius)[![GitHub Repo stars](https://camo.githubusercontent.com/c393f869873a99548f5631bfb0b9aed1683954c1fc3d3f1777d9b1fe60377f25/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f64657672616269756c2f6c61726176656c2d67656f2d67656e6975733f7374796c653d736f6369616c)](https://camo.githubusercontent.com/c393f869873a99548f5631bfb0b9aed1683954c1fc3d3f1777d9b1fe60377f25/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f64657672616269756c2f6c61726176656c2d67656f2d67656e6975733f7374796c653d736f6369616c)

Featured On
-----------

[](#featured-on)

I’m proud to share that **GeoGenius** was featured on **Laravel News** in their article: *“GeoGenius Package for Laravel”*.
Read it here: [GeoGenius Package for Laravel — Laravel News](https://laravel-news.com/geogenius-package-for-laravel)

---

🚀 Live Demo
-----------

[](#-live-demo)

👉 [Try the Live Demo](https://packages.rixetbd.com/devrabiul/laravel-geo-genius)

[![Live Demo Thumbnail](https://camo.githubusercontent.com/e6ef817365bec61051e842d1ed09fae802d399ec8ccb32fef47b67cc28f2a766/68747470733a2f2f7061636b616765732e726978657462642e636f6d2f73746f726167652f6170702f7075626c69632f7061636b6167652f64657672616269756c2f6c61726176656c2d67656f2d67656e6975732e77656270)](https://camo.githubusercontent.com/e6ef817365bec61051e842d1ed09fae802d399ec8ccb32fef47b67cc28f2a766/68747470733a2f2f7061636b616765732e726978657462642e636f6d2f73746f726167652f6170702f7075626c69632f7061636b6167652f64657672616269756c2f6c61726176656c2d67656f2d67656e6975732e77656270)

---

✨ Key Features
--------------

[](#-key-features)

- 🌐 **Automatic Timezone Detection** — via cookies, headers, or fallback strategies
- 🧠 **Timezone Conversion Helpers** — convert timestamps automatically
- 📱 **Country Picker &amp; Phone Validation** — detect visitor’s country, show dropdown, format &amp; validate numbers
- ⚡ **Lightweight &amp; Dependency-Free** — no jQuery or frontend frameworks required
- 🔄 **Livewire Compatible** — works seamlessly with Livewire apps
- 🔧 **Configurable Detection Strategy** — customise detection method per app requirements
- 📦 **Migration &amp; Artisan Support** — add `timezone` column effortlessly
- 🔒 **Caching &amp; Offline Support** — reduces API calls and handles offline gracefully
- 🌍 **Multilingual Ready** — built-in translation and auto-translation support

Under the hood, it leverages reliable **IP geolocation APIs** like [`ipwho.is`](https://ipwho.is) and [`ip-api.com`](http://ip-api.com) with caching for optimal performance.

---

📦 Installation
--------------

[](#-installation)

```
composer require devrabiul/laravel-geo-genius
```

Publish the configuration and migration stub:

```
php artisan vendor:publish --provider="Devrabiul\\LaravelGeoGenius\\LaravelGeoGeniusServiceProvider"
```

---

⚡ Quick Start
-------------

[](#-quick-start)

Use Laravel GeoGenius in two ways:

1. ✅ **Global Helper** — `laravelGeoGenius()` *(recommended)*
2. 🧰 **Service Class** — manually instantiate `GeoLocationService`

### Global Helper

[](#global-helper)

```
laravelGeoGenius()->geo()->locateVisitor();
laravelGeoGenius()->geo()->getCountry();
laravelGeoGenius()->geo()->getTimezone();
laravelGeoGenius()->geo()->getLatitude();
```

### Service Class

[](#service-class)

```
use Devrabiul\LaravelGeoGenius\Services\GeoLocationService;

$geo = new GeoLocationService();

$ip = $geo->getClientIp();
$locationData = $geo->locateVisitor();
```

---

🌐 Multilingual &amp; Translation
--------------------------------

[](#-multilingual--translation)

Built-in auto translation and number conversion:

```
use function Devrabiul\LaravelGeoGenius\geniusTrans;
use function Devrabiul\LaravelGeoGenius\geniusTranslateNumber;

echo geniusTrans('welcome_message');
echo geniusTranslateNumber(12345); // Bengali digits if locale is 'bn'
```

Configure in `config/laravel-geo-genius.php`:

```
'translate' => [
    'auto_translate' => true,
],
```

📝 Translation Artisan Commands
------------------------------

[](#-translation-artisan-commands)

Laravel GeoGenius provides a set of helpful artisan commands to manage languages and translations easily:

CommandDescription`php artisan geo:add-language {locale}`Create a new language directory with starter files (e.g. `en`, `bn`).`php artisan geo:translations-generate --locale={locale}`Scan your app for `translate('...')` calls and auto-generate `messages.php`.`php artisan geo:translate-language {locale} --count={n}`Translate up to `n` messages from `new-messages.php` into `messages.php`.`php artisan geo:translate-language-all {locale} --count={n}`Keep running batch translations until all strings are translated.`php artisan geo:translate-language-batch {locale} --count={n}`Translate a fixed batch of `n` messages at a time.### Examples

[](#examples)

```
# 1. Add English language support
php artisan geo:add-language en

# 2. Generate messages.php file from all translate() calls
php artisan geo:translations-generate --locale=en

# 3. Translate up to 100 strings for English
php artisan geo:translate-language en --count=100

# 4. Keep translating until all English strings are done (300 at a time)
php artisan geo:translate-language-all en --count=300

# 5. Translate 50 strings in a batch (useful for automation)
php artisan geo:translate-language-batch en --count=50
```

---

🌐 Change Current User Language
------------------------------

[](#-change-current-user-language)

You can programmatically change the current user's language using the `changeUserLanguage` method:

```
use Illuminate\Support\Facades\Route;

Route::get('/change-lang', function () {
    // Change current user language to Bengali
    laravelGeoGenius()->language()->changeUserLanguage('bn');

    // Continue your logic
    return redirect()->back();
});
```

> Supported locale codes depend on your configuration (`config/laravel-geo-genius.php`) and the languages you have added via `geo:add-language`.

🛠 Timezone Artisan Commands
---------------------------

[](#-timezone-artisan-commands)

Laravel GeoGenius ships with helpful artisan commands:

CommandDescription`php artisan geo:add-language {locale}`Add a new language (e.g. `en`, `bn`) to your app.### Examples

[](#examples-1)

```
# Add Bengali language
php artisan geo:add-language bn
```

---

🕒 Timezone Detection &amp; Conversion
-------------------------------------

[](#-timezone-detection--conversion)

```
use Devrabiul\LaravelGeoGenius\Services\TimezoneService;

$tz = new TimezoneService();

// Detect user's timezone
$timezone = $tz->getUserTimezone();

// Convert UTC datetime to user timezone
echo $tz->convertToUserTimezone('2025-09-13 15:00:00');
```

🛠 Timezone Artisan Commands
---------------------------

[](#-timezone-artisan-commands-1)

Laravel GeoGenius ships with helpful artisan commands:

CommandDescription`php artisan geo:add-timezone-column {table}`Add a nullable `timezone` column to the specified table if it does not exist.### Examples

[](#examples-2)

```
# Add a timezone column to the 'users' table
php artisan geo:add-timezone-column users
```

---

📱 Country Picker &amp; Phone Input
----------------------------------

[](#-country-picker--phone-input)

Laravel GeoGenius makes it trivial to initialise a **country-aware phone input field**:

- Auto-detects visitor’s **default country**
- Displays **country dropdown** (or restrict to one country)
- Formats phone numbers as the user types
- Provides **built-in validation** for numbers

### Quick Blade Example

[](#quick-blade-example)

```
>

    {!! laravelGeoGenius()->initIntlPhoneInput() !!}

```

GeoGenius injects the detected country code into a hidden span:

```

```

Then you can use intl-tel-input’s API to validate on submit:

```
const input = document.querySelector("#phone");
const iti = window.intlTelInput(input, {
    initialCountry: document.querySelector('.system-default-country-code').dataset.value,
    utilsScript: "https://cdn.jsdelivr.net/npm/intl-tel-input@19.2.15/build/js/utils.js",
});

form.addEventListener('submit', e => {
    if (!iti.isValidNumber()) {
        e.preventDefault();
        alert('Please enter a valid phone number');
    }
});
```

> All scripts/styles are included automatically by `initIntlPhoneInput()` — you only need to add the `` and optionally the validation snippet.

---

🌍 Restrict to Specific Countries
--------------------------------

[](#-restrict-to-specific-countries)

Laravel GeoGenius gives you full control over which countries appear in the **phone input dropdown**. You can either show **all countries** (default) or restrict it to **a specific set** such as only the U.S. and Canada.

This behavior is configured in your `config/laravel-geo-genius.php` file under the `phone_input` section.

### Example Configuration

[](#example-configuration)

```
'phone_input' => [
    'initial_country' => env('GEO_PHONE_DEFAULT_COUNTRY', 'us'),
    'only_countries_mode' => true, // enable restriction mode
    'only_countries_array' => ['us', 'ca'], // allowed countries only
    'auto_insert_dial_code' => false,
    'national_mode' => false,
    'separate_dial_code' => false,
    'show_selected_dial_code' => true,
    'auto_placeholder' => 'off',
],
```

When `only_countries_mode` is `true`, GeoGenius will:

✅ Restrict the dropdown list to countries in `only_countries_array`✅ Set the `initial_country` to the visitor’s detected country (if allowed) ✅ Fallback to the default country if the detected one isn’t in the list

If the mode is disabled (`false`), all countries are shown automatically.

---

🧠 Additional Notes
------------------

[](#-additional-notes)

- 🌐 **APIs Used:** [ipify.org](https://api.ipify.org), [ipwho.is](https://ipwho.is)
- 🔐 **Caching:** Geo data cached 7 days per IP (`ttl_minutes` = cache lifetime in minutes)
- ⚙️ **Fallback:** Returns default structure if offline
- 🧪 **Localhost Handling:** Fetches external IP for `127.0.0.1` or `::1`

---

🤝 Contributing
--------------

[](#-contributing)

We welcome contributions! Please:

1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests if applicable
5. Submit a pull request

Report bugs through [GitHub Issues](https://github.com/devrabiul/laravel-geo-genius/issues).

---

🌱 Treeware
----------

[](#-treeware)

This package is [Treeware](https://treeware.earth). If you use it in production, please [**buy the world a tree**](https://plant.treeware.earth/devrabiul/laravel-geo-genius) to thank us for our work. Your support helps create employment for local families and restores wildlife habitats.

---

📄 License
---------

[](#-license)

MIT License. See [LICENSE](https://github.com/devrabiul/laravel-geo-genius/blob/main/LICENSE) for details.

---

📬 Support
---------

[](#-support)

- 📧 Email:
- 🌐 GitHub: [devrabiul/laravel-geo-genius](https://github.com/devrabiul/laravel-geo-genius)
- 📦 Packagist: [packagist.org/packages/devrabiul/laravel-geo-genius](https://packagist.org/packages/devrabiul/laravel-geo-genius)

---

🔄 Changelog
-----------

[](#-changelog)

See [CHANGELOG.md](https://github.com/devrabiul/laravel-geo-genius/blob/main/CHANGELOG.md) for recent changes and updates.

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance73

Regular maintenance activity

Popularity43

Moderate usage in the ecosystem

Community13

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.5% 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 ~19 days

Total

6

Last Release

152d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9eaf28cb5d9d5d87660cbe335e7b82a08bc7801a40556c3a99740e22282d9e17?d=identicon)[devrabiul](/maintainers/devrabiul)

---

Top Contributors

[![devrabiul](https://avatars.githubusercontent.com/u/112581088?v=4)](https://github.com/devrabiul "devrabiul (21 commits)")[![rabiul6am](https://avatars.githubusercontent.com/u/128285760?v=4)](https://github.com/rabiul6am "rabiul6am (1 commits)")

---

Tags

country-pickergeolocationlaravelmultilingualpackagetimezoneuser-timezonelaravelinternationalizationgeolocationdatetimelocalegeotimezoneip-locationlaravel-timezonetimezone detectiontimezone conversionuser timezonegeo geniusregion detectioncountry detectioncontext-aware

### Embed Badge

![Health badge](/badges/devrabiul-laravel-geo-genius/health.svg)

```
[![Health](https://phpackages.com/badges/devrabiul-laravel-geo-genius/health.svg)](https://phpackages.com/packages/devrabiul-laravel-geo-genius)
```

###  Alternatives

[nnjeim/world

Laravel countries, states, cities, currencies, languages and IP geolocation

970361.2k3](/packages/nnjeim-world)[codezero/laravel-localized-routes

A convenient way to set up, manage and use localized routes in a Laravel app.

543638.1k4](/packages/codezero-laravel-localized-routes)[kslimani/laravel-geo

Laravel Geo.

1124.4k](/packages/kslimani-laravel-geo)[longman/laravel-multilang

Package to integrate multi language (multi locale) functionality in Laravel 5.x

5514.4k1](/packages/longman-laravel-multilang)[tigrov/yii2-country

Country data for Yii2 using Intl extension and more.

151.1k](/packages/tigrov-yii2-country)[jrmajor/fluent

Fluent localization system for PHP

2716.9k5](/packages/jrmajor-fluent)

PHPackages © 2026

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