finds.dev

clickbar/laravel-magellan

A modern PostGIS toolbox for Laravel

View on GitHub

★ 444PHPMITupdated Jun 2026

// the take

A Laravel package that wraps PostGIS in three layers: Schema blueprint methods for migrations, geometry data classes wired through Eloquent casts, and a typed `ST::` facade that turns PostGIS functions into query builder expressions. It suits Laravel apps already on Postgres that want spatial queries without hand-writing `ST_*` SQL.

- The `ST::` functions are real typed methods, so `ST::distanceSphere($point, 'location')` in a `where` or `orderBy` gets static checking and IDE completion instead of a SQL string that fails at runtime.

- Parsers and generators cover WKB, WKT and GeoJSON in both directions. The GeoJSON validation rule and form request trait accept a per-field SRID, so a payload in EPSG:25832 isn't quietly treated as 4326.

- `withMagellanCasts()` inspects the select list and adds Point, Polygon and Box casts for geometry-returning functions, so `ST::convexHull(...)` results hydrate into data classes without a hand-maintained `withCasts` array.

- `where(ST::contains(...), true)` needs the trailing boolean. Leave it off and Laravel builds a null check, which filters on the wrong thing without any error. The README warns about this, but the wrapper doesn't guard against it.

- Subqueries that cross database connections are a known gap. The expressions can't see the builder, so Laravel's database-name prefixing never happens and those queries need manual workarounds.

- Most of the schema API (`magellanPoint` and friends) is deprecated in favour of Laravel's native `geometry()` and `geography()`, and the README says the rest goes in the next major version. Existing migrations will need rewriting when that lands.

We read the README, the directory tree and a key source file in October 2026. Nobody pays to be listed. How we judge →

// at a glance

Stars
444
Forks
26
Language
PHP
License
MIT
Last commit
23 Jun 2026

// nearby

If laravel-magellan isn't quite it.

All repos →