Skip to content

Installation

mozrin edited this page Nov 18, 2026 · 2 revisions

Installation and datasets

Laravel 12 or 13, PHP 8.4.27+ within 8.4 or 8.5.12+ within 8.5. Querying/provisioning datasets also needs PDO SQLite with FTS5; provider discovery and the default disabled HTTP interface do not require installed data.

Until Packagist publication, add the public VCS repository to the consuming Laravel application's composer.json:

{"repositories": [{"type": "vcs", "url": "https://github.com/moztopia/moztopia-geolookup"}]}

Install the released package and publish its configuration:

composer require moztopia/geolookup:^0.9.0
php artisan vendor:publish --tag=geolookup-config

For local package development, replace the VCS entry with a path repository pointing to your source checkout:

{"repositories": [{"type": "path", "url": "/path/to/moztopia-geolookup"}]}

Check out develop in that source checkout and require dev-develop in the consuming application. Released consumers should use the numeric constraint above.

Laravel discovers the provider automatically. The package never downloads data or prompts during Composer installation. No application database migrations, queue workers, scheduler or UI are required.

Provision a local dataset

Use a new file in an existing directory. Existing files are never overwritten. Assign stable UUIDv4/v7 identities once and retain them across updates; external identifiers go in source, not id.

use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
use Moztopia\GeoLookup\Data\SqliteDataset;

$directory = storage_path('app/geolookup');
File::ensureDirectoryExists($directory);

SqliteDataset::create($directory.'/locations.sqlite', [
    [
        'id' => (string) Str::uuid(),
        'name' => 'Thailand',
        'type' => 'country',
        'country_code' => 'TH',
        'aliases' => ['TH'],
    ],
]);

That example creates only a selectable country, not a Thailand address dataset. Actual imports must provide the complete parent chain. Optional place fields: parent_id, local_type, aliases, postal_codes, source (provenance object), and relationships (list of {type, place_id}). The primary parent is the display/navigation chain; additional geographic relationships can represent overlaps without inventing a single county parent. They are metadata, not extra ancestors or search scopes.

An optional third argument supplies boundaries as a list of ['place_id' => $uuid, 'geometry' => $geoJsonGeometry]. Coordinates are WGS84 longitude/latitude pairs. The producer must establish source rights, version, completeness and valid non-self-intersecting topology. The package checks structural validity, not the legal authority of a border. Containment uses planar GeoJSON segments with longitude unwrapping, not geodesic surveying. Exterior edges match; holes are excluded, including their edges. See coverage and licensing for the distinction between reference data and official boundaries.

database/schema.sql documents storage schema 1. Use the provisioning API to build names, FTS context and readiness metadata together; applying that SQL alone does not build a ready dataset. Runtime connections are read-only. For updates, provision a new versioned file and switch the host configuration, then restart long-lived workers so they open the new file. Do not rewrite an active database in place.

Documentation home

by-dolly

Clone this wiki locally