grimzy/laravel-mysql-spatial
Laravel package for working with MySQL spatial data types and functions. Adds Eloquent support for geometry columns like POINT, LINESTRING and POLYGON, with spatial queries and helpers for storing, retrieving and querying geographic data in your models.
Architecture fit
point(), polygon(), geometrycollection() column types), the query builder (whereDistance, whereWithin, whereContains, orderByDistance), and Eloquent attribute casting (spatial columns hydrate into typed value objects rather than raw WKT/WKB).DB::raw('ST_GeomFromText(...)') and ST_Distance_Sphere string expressions, which are untestable and untyped. With it, the domain gets Point/Polygon value objects and the spatial predicate vocabulary is expressed once.Integration feasibility
brick/geo-style library), changed illuminate/* and PHP constraints, and any migration-grammar changes. Any prior 4.x PoC code must be re-validated, not merely re-pinned.NOASSERTION; a major release is a plausible moment for an accidental or deliberate relicense, and legal clearance is still a hard gate.Technical risk
ST_Distance_Sphere SRID preconditions and on whether geometries carry an SRID at all; MariaDB implements a different ST_* surface. Any portability claim must be proven on your actual target version.SPATIAL INDEX requires NOT NULL columns and an appropriate InnoDB version; naive adoption produces table scans that only appear under production data volume. Validate with EXPLAIN, never assume.Key questions
NOASSERTION license status on the 5.0.0 tag specifically?Stack fit
doctrine/dbal schema path remains the likely break point, and the new release does not move that needle at all.Migration path
ST_GeomFromText migrations — always nullable-first, backfill, then NOT NULL and index; never add a SPATIAL INDEX and a backfill in one migration on a large table.matanyadaev/laravel-eloquent-spatial, raw ST_* expressions, or a PostGIS adapter a bounded, single-package change rather than a codebase-wide grep.replace directive over an unpinned dev-branch dependency. Never point production at dev-master of an unmaintained single-maintainer repository.Compatibility
orderByDistance results are geodesic and monotonically sane at the equator, poles, and across the antimeridian; EXPLAIN shows the spatial index is used for whereWithin at target dataset size; and the same geometry read back on 5.7 and 8.0 produces identical coordinates.Sequencing
NOASSERTION) against the 5.0.0 tag — cheap, blocks everything, do it first.point column, run one distance query. Timebox to 2 days; the outcome is a Go/No-Go with a concrete patch list.EXPLAIN and latency benchmarks at realistic row counts.Maintenance
Support
Scaling
SPATIAL INDEX gives R-tree bounding-box filtering, which is excellent for "within this viewport / this radius" queries at scale. Distance ordering and filtering are not indexable in the general case: always prefilter with a bounding-box predicate (whereWithin) before orderByDistance, or a millisecond index scan becomes a full scan with per-row trigonometry.Failure modes
->change() or a column alteration on a spatial column fails due to doctrine/dbal handling in the migration path. Mitigation: rehearse destructive migrations on a production-sized snapshot.ST_* behavior. Mitigation: pin the engine version where the provider allows, and include a post-upgrade spatial smoke test in change management.Ramp-up
How can I help you explore Laravel packages today?