- How do I install martin-georgiev/postgresql-for-doctrine in a Laravel app?
- Install it with Composer using composer require martin-georgiev/postgresql-for-doctrine. In a Laravel app, add or publish a service provider that registers the package DBAL types with Doctrine, then reference the package type constants in your entity mappings. The README Quick Start shows Type::addType calls and DQL examples. Confirm your Doctrine bootstrap runs before the types are used.
- Does this package work with Laravel Eloquent or only Doctrine?
- The package is a Doctrine DBAL and ORM extension, not an Eloquent package. In Laravel it fits applications that use Doctrine for persistence, where you can register types and use DQL functions. Eloquent's query builder does not understand these DQL constructs, so window functions and most PostgreSQL-specific predicates will need raw expressions if you stay on Eloquent.
- Which PHP, PostgreSQL and Laravel versions does this package support?
- It requires PHP 8.2+ and PostgreSQL 9.4+, and it extends Doctrine DBAL/ORM rather than targeting a specific Laravel release. Laravel compatibility therefore follows the Doctrine DBAL/ORM version your app installs. Check the package Composer constraints and your Laravel-Doctrine integration before upgrading.
- How do I register the PostgreSQL DBAL types with Doctrine in Laravel?
- Register each type with Doctrine Type::addType, for example jsonb, text array and numrange, then use the matching constants in entity column mappings. The package service provider pattern or your existing Doctrine bootstrap can do this at application boot. The README Quick Start shows both registration and entity usage.
- What PostgreSQL data types does this package add to Doctrine?
- It adds Doctrine DBAL types for PostgreSQL arrays, JSONB, network types such as inet and cidr, geometric types, ranges, bit strings, and PostGIS geometry and geography, including array variants. That lets Doctrine hydrate and persist these values instead of treating every column as a string. Geometry and geography array columns also support geometry_type and srid options.
- Can I use PostgreSQL functions like CONTAINS or JSON_GET_FIELD in DQL?
- Yes. The package provides DQL functions for more than 100 PostgreSQL-specific operations, so predicates like CONTAINS and JSON_GET_FIELD can be expressed in Doctrine queries. This keeps PostgreSQL semantics inside the ORM layer instead of scattering DB::raw calls. Availability depends on the function and the Doctrine query layer you use.
- Does it support window functions and analytics like ROW_NUMBER, RANK and LAG?
- v4.9.0 adds ranking and value window functions such as ROW_NUMBER, RANK, LAG, LEAD and NTILE, plus OVER, FILTER and ordered-set aggregates like PERCENTILE_CONT. These are DQL constructs, so they work where queries go through Doctrine's DQL/ORM layer. If a target query runs through Eloquent's builder, expect to use raw SQL for most of them.
- How do I store and query PostGIS geometry columns and geometry arrays?
- Use the PostGIS geometry and geography types for scalar columns or arrays, and set geometry_type and srid where needed. v4.9.0 adds ST_MakeValid and ST_IsValidReason for validation and repair, WKT/EWKT conversion, and OGC accessors for geometry elements. That supports a pipeline of validate, repair, convert, access and analyse without DB::raw for each step.
- What should I check before upgrading to v4.9.0?
- The highest-priority change is that value objects now throw their own exception type, so catch blocks or retry policies keyed on older exceptions may stop catching. WktSpatialData::fromString was also renamed or normalized, so search for older factory calls. Treat the upgrade as verification: add regression tests for type hydration, exception handling, precision and ORM array reads.
- Is this package actively maintained, and what alternatives exist?
- The package is actively maintained, with v4.9.0 released in September 2026 after four minor releases since v4.5.1 in April 2026. For teams needing only one or two custom types, hand-written DBAL types or raw SQL may be simpler; for broad PostgreSQL semantics this package reduces bespoke SQL. In production, test against your actual PostgreSQL version and run upgrade checks on a staging database first.