Looking to hire Laravel developers? Try LaraJobs

geolocation-for-laravel maintained by roundly-consulting

Description
Resolve a client's location and travel distance through pluggable geolocation providers for Laravel.
Last update
2026/10/03 20:10 (dev-main)
License
Downloads
22

Comments
comments powered by Disqus

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.

License

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