finds.dev← search

// the find

clickbar/laravel-magellan

★ 444 · PHP · MIT · updated Jun 2026

A modern PostGIS toolbox for Laravel

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.

View on GitHub →

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →