PHPackages                             3neti/form-handler-location - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. 3neti/form-handler-location

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

3neti/form-handler-location
===========================

Location capture handler for form flow system

v1.1.1(4mo ago)01.1kMITPHPPHP ^8.2

Since Dec 24Pushed 4mo agoCompare

[ Source](https://github.com/3neti/form-handler-location)[ Packagist](https://packagist.org/packages/3neti/form-handler-location)[ RSS](/packages/3neti-form-handler-location/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (7)Versions (3)Used By (0)

Location Handler Plugin
=======================

[](#location-handler-plugin)

A Form Flow Manager plugin for capturing user location using browser geolocation API.

Features
--------

[](#features)

✅ Browser geolocation capture (GPS coordinates)
✅ Reverse geocoding (coordinates → address)
✅ Map snapshot generation (Google Maps / Mapbox)
✅ Address component extraction (street, city, region, etc.)
✅ Accuracy measurement
✅ Auto-registration with Form Flow Manager

Installation
------------

[](#installation)

```
composer require 3neti/form-handler-location
```

That's it! The handler automatically registers itself with the Form Flow Manager.

Configuration
-------------

[](#configuration)

Publish the config file:

```
php artisan vendor:publish --tag=location-handler-config
```

Edit `config/location-handler.php`:

```
return [
    'opencage_api_key' => env('VITE_OPENCAGE_KEY'),  // For reverse geocoding
    'map_provider' => env('LOCATION_HANDLER_MAP_PROVIDER', 'google'),
    'mapbox_token' => env('VITE_MAPBOX_TOKEN'),
    'google_maps_api_key' => env('GOOGLE_MAPS_API_KEY'),
    'capture_snapshot' => true,
    'require_address' => false,
];
```

### Environment Variables

[](#environment-variables)

Add to `.env`:

```
# OpenCage API (reverse geocoding)
VITE_OPENCAGE_KEY=your_opencage_api_key

# Map Provider (optional)
LOCATION_HANDLER_MAP_PROVIDER=google  # or 'mapbox'

# Mapbox (if using Mapbox)
VITE_MAPBOX_TOKEN=your_mapbox_token

# Google Maps (optional, for static maps)
GOOGLE_MAPS_API_KEY=your_google_maps_key
```

Usage
-----

[](#usage)

### In a Form Flow

[](#in-a-form-flow)

```
const response = await fetch('/form-flow/start', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
        reference_id: 'unique-id',
        steps: [
            {
                handler: 'location',
                config: {
                    title: 'Your Location',
                    description: 'We need your location to continue',
                    require_address: true,
                    capture_snapshot: true,
                    map_provider: 'google'
                }
            }
        ],
        callbacks: {
            on_complete: 'https://your-app.test/callback'
        }
    })
});
```

### Configuration Options

[](#configuration-options)

OptionTypeDefaultDescription`require_address`boolean`false`Require reverse geocoded address`capture_snapshot`boolean`true`Capture map image as base64`map_provider`string`'google'`Map provider: `'google'` or `'mapbox'``title`string-Custom step title`description`string-Custom step descriptionCollected Data
--------------

[](#collected-data)

The handler returns the following data structure:

```
[
    'latitude' => 14.5995,
    'longitude' => 120.9842,
    'formatted_address' => 'Makati City, Metro Manila, Philippines',
    'address_components' => [
        'street' => 'Ayala Avenue',
        'barangay' => 'Poblacion',
        'city' => 'Makati City',
        'region' => 'Metro Manila',
        'country' => 'Philippines',
        'postal_code' => '1200'
    ],
    'snapshot' => 'data:image/png;base64,iVBORw0KG...',  // Map image
    'accuracy' => 10.5,  // meters
    'timestamp' => '2024-12-12T10:30:00+08:00'
]
```

Testing
-------

[](#testing)

```
cd packages/form-handler-location
composer test
```

### Test Coverage

[](#test-coverage)

- ✅ Interface implementation
- ✅ Coordinate validation
- ✅ Address handling
- ✅ Map snapshot support
- ✅ Accuracy metrics
- ✅ Config schema
- ✅ Inertia rendering

How It Works
------------

[](#how-it-works)

### 1. Plugin Auto-Registration

[](#1-plugin-auto-registration)

```
// LocationHandlerServiceProvider::boot()
protected function registerHandler(): void
{
    $handlers = config('form-flow.handlers', []);
    $handlers['location'] = LocationHandler::class;
    config(['form-flow.handlers' => $handlers]);
}
```

### 2. Browser Geolocation

[](#2-browser-geolocation)

The Vue component (`LocationCapturePage.vue`) uses:

```
navigator.geolocation.getCurrentPosition((position) => {
    const coords = {
        latitude: position.coords.latitude,
        longitude: position.coords.longitude,
        accuracy: position.coords.accuracy
    };
    // Submit to handler...
});
```

### 3. Reverse Geocoding

[](#3-reverse-geocoding)

Uses OpenCage API to convert coordinates to address:

```
(14.5995, 120.9842) → "Makati City, Metro Manila, Philippines"

```

### 4. Map Snapshot

[](#4-map-snapshot)

Generates static map image via Google Maps or Mapbox API.

Architecture
------------

[](#architecture)

This is a **plugin package** for Form Flow Manager:

```
form-handler-location/     (Plugin)
├── Implements FormHandlerInterface
├── Self-registers via service provider
└── Optional dependency

form-flow-manager/         (Core)
├── Discovers plugins automatically
└── Orchestrates flow with registered handlers

redeem-x/                  (Host App)
└── Installs: core + chosen plugins

```

### Plugin Benefits

[](#plugin-benefits)

✅ **Optional** - Install only if needed
✅ **Independent** - Tested separately
✅ **Reusable** - Works across different apps
✅ **Maintainable** - Clean separation of concerns

Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 12+
- Form Flow Manager (`lbhurtado/form-flow-manager`)
- Browser with geolocation support

API Keys
--------

[](#api-keys)

### OpenCage (Free Tier)

[](#opencage-free-tier)

- Sign up:
- Free: 2,500 requests/day
- Used for: Reverse geocoding

### Mapbox (Optional)

[](#mapbox-optional)

- Sign up:
- Free: 50,000 requests/month
- Used for: Static map images

### Google Maps (Optional)

[](#google-maps-optional)

- Sign up:
- Free: Basic usage (with limits)
- Used for: Static map images

Troubleshooting
---------------

[](#troubleshooting)

### "Handler not found: location"

[](#handler-not-found-location)

**Solution:**

```
php artisan config:clear
php artisan cache:clear
composer dump-autoload
```

### Location not captured

[](#location-not-captured)

**Check:**

1. HTTPS enabled? (required for geolocation)
2. User granted permission?
3. Browser supports geolocation?

### Reverse geocoding fails

[](#reverse-geocoding-fails)

**Check:**

1. OpenCage API key configured?
2. API key valid?
3. Request quota not exceeded?

Related Packages
----------------

[](#related-packages)

- [form-flow-manager](../form-flow-manager) - Core orchestration
- [form-handler-selfie](../form-handler-selfie) - Camera capture
- [form-handler-signature](../form-handler-signature) - Digital signature
- [form-handler-kyc](../form-handler-kyc) - Identity verification

License
-------

[](#license)

MIT

Author
------

[](#author)

3neti

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance76

Regular maintenance activity

Popularity20

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~15 days

Total

2

Last Release

130d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/586e1ed70140038e6348728222adbcf68bfc4455b1f94a4f8bcbe57917a63d57?d=identicon)[3neti](/maintainers/3neti)

---

Top Contributors

[![3neti](https://avatars.githubusercontent.com/u/89447696?v=4)](https://github.com/3neti "3neti (3 commits)")

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/3neti-form-handler-location/health.svg)

```
[![Health](https://phpackages.com/badges/3neti-form-handler-location/health.svg)](https://phpackages.com/packages/3neti-form-handler-location)
```

###  Alternatives

[illuminate/pipeline

The Illuminate Pipeline package.

9346.6M213](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10532.5M862](/packages/illuminate-pagination)[mrmarchone/laravel-auto-crud

Laravel Auto CRUD helps you streamline development and save time.

28711.8k2](/packages/mrmarchone-laravel-auto-crud)[spatie/laravel-mix-preload

Add preload and prefetch links based your Mix manifest

169176.0k2](/packages/spatie-laravel-mix-preload)[interaction-design-foundation/laravel-geoip

Support for multiple Geographical Location services.

17221.0k3](/packages/interaction-design-foundation-laravel-geoip)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
