LaravelPackages.net
Acme Inc.
Toggle sidebar
roundly-consulting/geolocation-for-laravel

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

203
0
2.0.4
About roundly-consulting/geolocation-for-laravel

roundly-consulting/geolocation-for-laravel is a Laravel package for resolve a client's location and travel distance through pluggable geolocation providers for laravel.. It currently has 0 GitHub stars and 203 downloads on Packagist (latest version 2.0.4). Install it with composer require roundly-consulting/geolocation-for-laravel. Discover more Laravel packages by roundly-consulting or browse all Laravel packages to compare alternatives.

Last updated

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, with the Geocoding API and the Routes API enabled on that key.

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.

Comments