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.
ST_* spatial functions. It lets you answer "should we build proximity search / store locator / delivery-radius filtering / point-in-polygon zone checks?" without a separate geo service. That makes it a cheap spike tool: one engineer, one sprint, a real answer on performance and data quality.matanyadaev/laravel-eloquent-spatial (MySQL 8 + Postgres/MariaDB, current Laravel), (c) raw DB::raw / selectRaw with ST_Distance_Sphere, (d) a dedicated geo store (PostGIS, or a search index like Meilisearch/Elasticsearch geo). The package's real value is in demonstrating the schema and query patterns you'd otherwise hand-roll.POINT/POLYGON columns with a fixed SRID (vs. plain lat/lng decimals) is a one-way-ish door: it affects spatial index viability, reporting/BI tooling, and vendor portability. Spatial indexes in MySQL also require NOT NULL columns and InnoDB — a constraint that surfaces as a schema decision, not a code decision.Consider it when:
composer.json before committing — do not trust the README.Look elsewhere when:
matanyadaev/laravel-eloquent-spatial, which is the maintained continuation and supports SRID-aware geography semantics properly.NOASSERTION; the copyright and grant terms need a legal read before it goes into a commercial product. If your org requires an OSI-verified identifier, that alone may end the evaluation.To executives: This is a free, small open-source library that lets our Laravel app store map coordinates and answer "what's near me" questions using the database we already run. It costs nothing to try and could let us ship location search in one sprint rather than buying a geo platform contract. The caveat is age: the last release was October 2020 and the project shows no active dependents, so we should treat it as a reference implementation to copy or fork, not a permanent dependency. Recommendation: fund a one-sprint spike to validate the feature and the query performance; if geo becomes a real product surface, budget a follow-on migration to the maintained fork or PostGIS. The decision we need from you is narrower than it looks — is location search a differentiator or table stakes? That answer determines whether we spend one sprint or one quarter.
To engineering: The package gives you Eloquent casts for POINT, POLYGON, LINESTRING, etc., plus query scopes for distance and containment, backed by MySQL's ST_* functions and spatial indexes. Assume you will own it: pin it, read the source, verify Laravel/PHP compatibility before adopting, and prefer matanyadaev/laravel-eloquent-spatial if you need a maintained path or Postgres. Watch the sharp edges — SRID consistency, NOT NULL requirements for spatial indexes, and the difference between planar and spherical distance. If you'd spend more time fighting the abstraction than writing selectRaw('ST_Distance_Sphere(...)'), skip the package and write the SQL.
How can I help you explore Laravel packages today?