Download the PHP package mayaram/laravel-browser-location without Composer

On this page you can find all versions of the php package mayaram/laravel-browser-location. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-browser-location

Laravel Browser Location

Capture browser-based GPS location in Laravel using the HTML5 Geolocation API.
Works with Laravel 10-13, plain Blade, and Livewire 3 / 4.

Table of Contents


Core features


Installation

Run the installer command:

This publishes config / views / migrations and runs migrations automatically.


Usage: Blade component

Drop the tracker anywhere in any Blade view — including inside a Livewire component:

Default behaviour: auto-capture="true" and force-permission="true" are on by default, so the browser will request the user's location immediately. Set them to false if you want manual control.

All Component Props

Prop Type Default Description
button-text string 'Share GPS location' Label for the (hidden by default) trigger button.
auto-capture bool true Requests location on page load and after every Livewire navigation.
force-permission bool true Shows a full-screen overlay until the user grants permission.
watch bool false Continuously tracks position using watchPosition().
livewire-method string 'setBrowserLocation' Livewire component method called on successful capture. Leave empty in plain Blade.
required-accuracy-meters float 200 Threshold for the is_accurate flag in the payload.
enable-high-accuracy bool true Requests the most accurate reading from the device GPS.
timeout int 12000 Milliseconds before the location request times out.
maximum-age int 0 Milliseconds a cached location is considered fresh (0 = always fresh).
auto-save bool false Automatically POSTs captures to the package save endpoint.
capture-endpoint string '/browser-location/capture' Endpoint used by JS for automatic persistence.
collection-name string 'default' Target location collection for automatic save.
locationable-type string auth user morph class Override the model class that owns the location (must be allow-listed).
locationable-id mixed auth user key Override the model key.
event-name string 'browser-location:updated' JS event dispatched on successful capture.
error-event-name string 'browser-location:error' JS event dispatched on error.
permission-event-name string 'browser-location:permission' JS event dispatched when permission state changes.

Example with custom options:

Browser Events

The tracker dispatches these native DOM events on document:

Event Description
browser-location:updated Successful capture — payload contains full location data
browser-location:error Error — payload contains code and message
browser-location:permission Permission state changed — payload contains state
browser-location:saved Location persisted to DB — payload contains persistence result
browser-location:save-error Persistence request failed

JavaScript API


Configuration

Creates config/browser-location.php. Key options:


Geocoder service (Google / Mapbox / OpenStreetMap)

Configure provider in .env

Usage via facade

Usage via dependency injection (preferred)

Normalized response shape

Best practices


Location persistence collections

1) Add the HasLocations trait to your model

2) Save locations manually (Spatie-style API)

3) Read stored locations

4) Automatic saving flow (no manual save required)

When <x-browser-location-tracker /> captures a location the package:

  1. POSTs coordinates to POST /browser-location/capture
  2. Validates via browser-location.validate middleware
  3. Applies quality checks (accuracy threshold + anti-duplicate rules)
  4. Persists in browser_locations and enriches meta with raw GPS, geocoder response, IP, user-agent

Persistence config

Optional explicit locationable models


Livewire integration (v3 & v4)

Basic setup

1. Add the trait to your Livewire component:

2. Add the tracker inside the component's Blade view:


Trait helper methods

All methods are available on any Livewire component that uses InteractsWithBrowserLocation:

Coordinate helpers

Method Returns Description
hasLocation() bool true once the browser sends valid coordinates
getLatitude() ?float Captured latitude
getLongitude() ?float Captured longitude
getAccuracy() ?float GPS accuracy in metres
getAccuracyLevel() string 'excellent' / 'good' / 'poor' / 'unknown'
browserLocationIsAccurate(?float $max) bool Whether accuracy is within the given or configured threshold

Permission & error helpers

Method Returns Description
getLocationPermission() ?string 'granted', 'denied', 'prompt', or null
isLocationDenied() bool Quick check for denied permission
getLocationErrorCode() ?int 1 = denied, 2 = unavailable, 3 = timeout
getLocationErrorMessage() ?string Human-readable error from the browser

Other helpers

Method Description
setBrowserLocation(array $location) Receives the payload from JS (called automatically)
resetBrowserLocation() Clears $browserLocation (e.g. after saving a trip)
getBrowserLocationJson() Returns the raw payload as a JSON string

Lifecycle hook (onBrowserLocationUpdated)

Implement this method on your component to react every time a new location arrives:


Livewire 3 & 4 — recommended attributes

The trait itself does not include #[Locked] or #[On] because Livewire is an optional dependency. Add them directly on your component for the best security and DX:

Both #[Locked] and #[On] work identically in Livewire 3 and Livewire 4.


Livewire 4: using #[On] to react via JS dispatch

An alternative to having JS call setBrowserLocation directly is to dispatch a browser event and let Livewire 4's #[On] handle it:


Compatibility matrix

Framework support

Laravel version Support
10.x
11.x
12.x
13.x
Feature Plain Blade Livewire 3 Livewire 4
<x-browser-location-tracker>
Auto-capture on page load
Hidden form inputs
wire:ignore prevents DOM morphing
JS calls Livewire method on capture
Re-capture after Livewire navigate
InteractsWithBrowserLocation helpers
#[Locked] / #[On] on your component

Middleware Validation

The middleware accepts location from:


Testing


License

MIT


All versions of laravel-browser-location with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/http Version ^10.0|^11.0|^12.0|^13.0
illuminate/support Version ^10.0|^11.0|^12.0|^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mayaram/laravel-browser-location contains the following files

Loading the files please wait ...