Search by

roundly-consulting / geolocation-for-laravel

mihaliak

Resolve a client's location and travel distance through pluggable geolocation providers for Laravel.

Package info

github.com/roundly-consulting/geolocation-for-laravel

pkg:composer/roundly-consulting/geolocation-for-laravel

Fund package maintenance!

Patreon

Statistics

Installs: 22

Dependents: 3

Suggesters: 1

Stars: 0

Open Issues: 0

1.0.0 2026-10-03 18:10 UTC

This package is auto-updated.

Last update: 2026-10-03 18:31:20 UTC


README

Geolocation for Laravel — Roundly open source

Latest release Tests Code style Donate Patreon Crypto

Geolocation for Laravel

Resolve a client's location from an IP address, coordinates or a street address, and the travel distance between two points, through a pluggable pipeline of providers: IPinfo, IP2Location, Google, MaxMind (with a native .mmdb reader) and a configurable fallback.

Installation

Requires PHP 8.4 and Laravel 12 or 13.

composer require roundly-consulting/geolocation-for-laravel

IP lookups work out of the box through IP2Location and IPinfo. Address lookups and distances go through Google and need GOOGLE_MAPS_API_KEY in your .env.

Usage

Locate the visitor, geocode an address and measure a drive, all through the facade:

use RoundlyConsulting\Geolocation\DataTransferObjects\Coordinates;
use RoundlyConsulting\Geolocation\Enum\DistanceType;
use RoundlyConsulting\Geolocation\Facades\Geolocation;

$location = Geolocation::locateRequest();          // the client's IP; null when nothing resolves

$location?->city;              // "Mountain View"
$location?->countryIsoCode;    // "US"
$location?->timezone;          // "America/Los_Angeles"

$office = Geolocation::locateAddress('1600 Amphitheatre Pkwy, Mountain View');
$office?->coordinates();       // Coordinates(37.4224, -122.0841)

$distance = Geolocation::distanceBetween(
    new Coordinates(48.1482, 17.1067),
    new Coordinates(49.2000, 16.6068),
    DistanceType::Driving,
);

$distance?->humanReadableDistance;   // "133 km"
$distance?->durationInSeconds;       // 5400

Documentation

The full documentation — configuration, every feature and its API, and testing — lives on our website: roundly-consulting.com/open-source/docs/geolocation-for-laravel

Release notes are in CHANGELOG.md. To contribute, see the contributing guide.

Support our work

This package is free and open source, built and maintained by Roundly Consulting. If it saves you time, please consider supporting our open-source work — a one-time donation, a monthly pledge on Patreon or a crypto donation helps fund maintenance, new features and new packages.

Donate to Roundly open source Become a patron on Patreon Donate crypto: BTC, ETH, BNB or SOL

License

The MIT License (MIT). See LICENSE.md.