Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Doctrine Postgis Laravel Package

jsor/doctrine-postgis

Adds PostGIS spatial support to Doctrine DBAL/ORM: geometry and geography column types, schema helpers, SQL and DQL functions, and spatial query integration for PostgreSQL/PostGIS.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit. jsor/doctrine-postgis is a persistence-layer adapter: it registers PostGIS geometry/geography column types with Doctrine DBAL and exposes PostGIS functions (distance, containment, intersection, etc.) to Doctrine's query layer. It is a narrow, well-scoped fit. In a Laravel codebase the value proposition collapses unless the data access layer already uses Doctrine DBAL/ORM — Laravel's default Eloquent path bypasses DBAL type mapping entirely, so the package provides no benefit to a pure Eloquent application. The realistic adoption pattern is either (a) a Laravel app already using laravel-doctrine, (b) a Doctrine-based service co-hosted with a Laravel front end, or (c) a module where Doctrine DBAL is deliberately introduced for spatial work. If the requirement is simply "store a lat/lng and do proximity search," an Eloquent-native PostGIS package or parameterized raw SQL is a lighter answer and should be evaluated as the baseline before adopting this one.

Integration feasibility. Composer install is trivial; the real work is configuration and schema ownership. The team must register the DBAL types, declare a mapping_types entry for the PostGIS column names, ensure the PDO pgsql driver is in use, and confirm the target database actually has the PostGIS extension enabled. Migrations become the friction point: Doctrine's schema tool and Laravel's migration system are two sources of truth unless one is designated authoritative, and spatial indexes (GiST) frequently need explicit, hand-written DDL that neither tool generates correctly by default. Expected effort is low for a proof of concept, moderate for production hardening — dominated by index and SRID conventions rather than by the package itself.

Technical risk. Three risks matter. First, dependency risk: the package sits on top of Doctrine DBAL, and in Laravel that means laravel-doctrine must support the current Laravel and PHP versions — this transitive chain, not jsor/doctrine-postgis, is the most likely thing to break on upgrade. Second, correctness risk: SRID mismatches, geometry-vs-geography semantics, and invalid geometries fail quietly or return wrong distances rather than throwing, which is a class of bug that surfaces in production as bad search results. Third, maintainer risk: MIT-licensed, single-primary-maintainer, ~221 stars — small but active (recent 2025 release). The blast radius is contained because the package is thin and replaceable with raw SQL, which is the mitigating factor to note.

Key questions. Does the product actually need spatial queries (proximity, geofencing, route/heatmap analytics), or is this a "someday" capability? Is PostgreSQL with PostGIS already the system of record, or would this introduce a second database engine? Is Doctrine already in the stack, or is this a covert ORM migration? What are the query patterns and expected row counts — point-in-polygon at scale behaves very differently from nearest-neighbor lookups? Who owns GIS conventions (SRID, coordinate order, precision) on the team? And what is the exit cost if we need to drop it?

Integration Approach

Stack fit. Green-light only for PostgreSQL + PostGIS. Verify extension availability on the target platform (RDS, Cloud SQL, Azure Database for PostgreSQL, Supabase, Neon all differ in what they enable by default and which PostGIS versions they expose). Confirm PHP and Doctrine DBAL versions align with the release matrix, and specifically confirm the laravel-doctrine (or equivalent) bridge supports the Laravel version in use before committing.

Migration path. Introduce the package behind a single bounded context — one spatial feature, one repository — rather than retrofitting the whole persistence layer. Steps: enable PostGIS in each environment including CI; install and register the DBAL types; add spatial columns via the designated migration tool; backfill from existing lat/lng or address data; build GiST indexes explicitly; then layer query code on top. Keep an ADR recording the decision to use Doctrine DBAL for this module so it isn't mistaken for a stack-wide ORM shift.

Compatibility. Validate three axes: framework (Laravel major version plus the Doctrine bridge), database (PostGIS version and managed-service feature parity), and driver (pdo_pgsql, connection pooling behavior with PgBouncer in transaction mode). Pin versions in composer.json and add a CI job that runs the spatial test suite against a PostGIS-enabled container so drift is caught at PR time, not at deploy.

Sequencing. (1) Spike: one table, one geometry column, one proximity query, measured against a raw-SQL baseline; (2) platform readiness: PostGIS in all environments, managed-service confirmation; (3) migration and index conventions documented; (4) feature implementation with query-plan review; (5) production hardening — observability on slow spatial queries, rollback plan. Gate progression at step 1: if raw SQL meets the need with comparable clarity, stop and skip the dependency.

Operational Impact

Maintenance. Low ongoing effort for the package itself — thin integration surface, MIT license, active recent release. The recurring cost is elsewhere: keeping the Doctrine bridge current with Laravel upgrades, and keeping spatial DDL in sync across environments. Assign explicit ownership of the schema and of GIS conventions; unowned spatial code drifts into inconsistent SRIDs quickly.

Support. Community-only. No vendor SLA. Acceptable for a contained, replaceable dependency; not acceptable if spatial queries become a revenue-critical path without an internal owner who understands both Doctrine and PostGIS. Budget for one engineer to reach that competency.

Scaling. PostGIS itself scales well given correct GiST indexing; the risks are self-inflicted. Watch for missing or unused indexes (bounding-box predicates before exact geometry tests), large WKB payloads crossing the PHP boundary, geography vs geometry choice affecting CPU cost per query, and connection poolers interfering with prepared statements. Load-test with realistic cardinality before launch, and review EXPLAIN ANALYZE output for every new spatial query pattern.

Failure modes. Missing PostGIS extension in a newly provisioned environment; SRID or axis-order mismatch producing silently wrong distances; schema drift between Doctrine and Laravel migrations; invalid geometries rejected at write time only; index not used after a data-volume change; upgrade breakage in the Doctrine bridge rather than in this package. Each maps to a cheap guardrail: environment smoke test, a canonical SRID constant, one migration authority, geometry validation on ingest, query-plan checks in CI, and version pinning.

Ramp-up. Eloquent-fluent developers face a real learning curve on Doctrine's unit-of-work, annotations/attributes, and DQL, plus GIS fundamentals. Estimate one to two weeks to productive for a mid-level engineer on the Doctrine side, with GIS concepts absorbed on the job. Weigh that against the alternative — raw SQL plus a thin repository — which is faster to adopt but cedes type safety and query composition. The honest TPM framing: this package is a good tool for a Doctrine-on-Postgres team and a poor fit for an Eloquent-only Laravel team; the decision hinges on the ORM question, not on the package's quality.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator
equipc/laravel-email-database-log
adedsec/nova-translated-labels
wazza/laravel-db-encryption
hokny/laravel-generator
vonsogt/backup
jengo/queues
jeremykenedy/laravel-observability
coleus/frame
thtg88/journalism
filagora/filagora-ai-forums