ermradulsharma/omnilocate

OmniLocate: Advanced user location detection for Laravel with persistence, caching, and distance utilities.

Fund package maintenance!
ermradulsharma

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/ermradulsharma/omnilocate

v1.0.0 2026-02-04 18:05 UTC

This package is auto-updated.

Last update: 2026-02-08 13:05:50 UTC


README

OmniLocate Banner

OmniLocate

Build Status Total Downloads License PHP Version

OmniLocate is a premium, high-performance user location detection package for Laravel. It provides a robust, developer-friendly API for identifying visitor details via IP address, featuring advanced caching, multi-driver support with intelligent fallbacks, and seamless integration with CDNs like Cloudflare and Akamai.

๐Ÿš€ Key Features

  • ๐ŸŒ Intelligent Detection: Works out-of-the-box with various IP services and CDN headers.
  • ๐Ÿ›ก๏ธ Smart Fallbacks: Chain multiple drivers to ensure location data is always available.
  • โšก Performance First: Integrated Laravel caching to minimize external API calls.
  • ๐Ÿ“ Geo-Utilities: Built-in distance calculation between any two detected points.
  • ๐Ÿค– Bot Filtering: Automatically skips detection for major search engine bots.
  • ๐Ÿงฉ Fluent API: Elegant, human-readable syntax for all operations.
  • ๐ŸŽจ Blade Integration: Simple directives to display location data directly in your templates.

๐Ÿ› ๏ธ Installation

Install OmniLocate via Composer:

composer require ermradulsharma/omnilocate

The package will automatically register its service provider and facade.

Configuration

Publish the configuration file to customize your drivers and settings:

php artisan vendor:publish --provider="Ermradulsharma\OmniLocate\LocationServiceProvider"

This creates config/location.php (or config/config.php depending on your setup).

๐Ÿ“– Basic Usage

Detect Current Visitor

Detect the location of the current user based on their IP address:

use Ermradulsharma\OmniLocate\Facades\Location;

if ($position = Location::get()) {
    echo $position->countryName; // "India"
    echo $position->cityName;    // "Mumbai"
    echo $position->flag();      // "๐Ÿ‡ฎ๐Ÿ‡ณ"
}

Detect Specific IP

$position = Location::get('8.8.8.8');

๐Ÿ”— Advanced Driver Chain & Fallbacks

OmniLocate excels at reliability. You can define a default driver and any number of fallbacks in your configuration, or add them dynamically:

Dynamic Fallbacks

use Ermradulsharma\OmniLocate\Facades\Location;
use Ermradulsharma\OmniLocate\Drivers\IpApi;

// Add a fallback driver dynamically at runtime
Location::fallback(new IpApi());

๐Ÿงฉ Extra Features

Blade Directives

Quickly display location info in your views:

Current Country: @location('countryName')
Your Flag: @location('flag')

Distance Utilities

Calculate the distance in Kilometers between two locations:

$distance = $position->distanceTo($otherPosition);

Validation Rules

Ensure users are from a specific location using Laravel's validation:

$request->validate([
    'signup_ip' => 'required|location:India',
]);

๐Ÿ“ฆ Supported Drivers

OmniLocate supports a variety of drivers out of the box:

  • HttpHeader: (Default) Detects location via CDN headers like CF-IPCountry.
  • IpApi: Free and Pro IP-API service.
  • IpData: Powerful IP Intelligence API.
  • IpInfo: Detailed IP address data.
  • GeoPlugin: Simple and effective geolocation service.
  • MaxMind: Local database and web service support.

๐Ÿงช Testing

Run the test suite using PHPUnit:

vendor/bin/phpunit

๐Ÿค Support & Funding

If you find this package useful, please consider supporting the developer:

โš–๏ธ License

Distributed under the MIT License. See LICENSE for more information.