Weave Code
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
Postgresql For Doctrine

Postgresql For Doctrine Laravel Package

martin-georgiev/postgresql-for-doctrine

Adds PostgreSQL-specific power to Doctrine DBAL/ORM: rich native types (jsonb, arrays, ranges, network, geometric, etc.) plus DQL functions/operators for JSON and array querying. Supports PostgreSQL 9.4+ and PHP 8.2+.

View on GitHub
Deep Wiki
Context7

Extends Doctrine with native PostgreSQL support for arrays, JSONB, ranges, PostGIS geometries, text search, ltree, uuid, and 100+ PostgreSQL-specific functions.

Frequently asked questions about Postgresql For Doctrine
Can I use this package with Laravel Eloquent instead of Doctrine ORM?
No, this package is designed specifically for Doctrine ORM. If you're using Eloquent, you'll need to either switch to Doctrine or build custom query logic to bridge PostgreSQL-specific features. The package integrates directly with Doctrine's DQL and type system, which Eloquent doesn't support natively.
What Laravel versions and PHP versions are officially supported?
This package requires PHP 8.2+ and works with any Laravel version that supports Doctrine ORM (e.g., Laravel 9+). The core dependency is on Doctrine DBAL/ORM, so compatibility depends on your Doctrine version. Always check the package's `composer.json` for exact PHP and Doctrine version requirements.
How do I enable PostGIS support in my Laravel application?
First, ensure the `postgis` extension is enabled in your PostgreSQL database. Then, register the `Geometry` type in Doctrine using `Type::addType('geometry', PostgresType::GEOMETRY)`. You may also need to run `CREATE EXTENSION IF NOT EXISTS postgis` in a Laravel migration or seed file to enable the extension.
Will this package work with existing PostgreSQL databases that have JSONB or array columns?
Yes, but you may need to update your Doctrine entity mappings to use the custom types (e.g., `type: PostgresType::JSONB`). The package provides backward compatibility for reading existing data, but writing new data requires explicit type registration. Test migrations thoroughly to avoid schema conflicts.
How do I query JSONB fields in Doctrine using this package?
Use Doctrine's DQL functions like `JSON_GET_FIELD`, `JSON_CONTAINS`, or `JSON_EXTRACT_PATH`. For example, `WHERE JSON_GET_FIELD(e.data, '$.field') = :value` or `WHERE JSON_CONTAINS(e.data, :jsonValue)`. The package extends Doctrine's query capabilities to work natively with PostgreSQL's JSONB operators.
Are there performance considerations when using complex types like ranges or geometries?
Yes, operations like spatial queries (PostGIS) or range comparisons can introduce overhead. Always use `EXPLAIN ANALYZE` in PostgreSQL to profile query performance. Indexing (e.g., GIST or GiST indexes for geometries) and optimizing DQL functions can significantly improve speed.
Can I use this package with Laravel's query builder instead of Eloquent or Doctrine?
No, this package is designed for Doctrine ORM, not Laravel's query builder. However, you could create a custom query builder wrapper that translates Laravel queries into DQL using this package's types and functions. This would require significant custom development.
What happens if I upgrade PostgreSQL from 9.4 to a newer version? Will this package still work?
This package supports PostgreSQL 9.4+, so upgrades within that range are generally safe. However, new PostgreSQL versions may introduce breaking changes in data types or functions. Always test thoroughly after upgrading, especially if using advanced features like PostGIS or custom arrays.
How do I test this package in a Laravel application before production?
Start by registering the types in a test environment and writing unit tests for your Doctrine entities. Use Laravel's `phpunit` with a test database to verify CRUD operations, queries, and edge cases (e.g., null values in arrays or invalid JSONB). The package includes integration tests as a reference.
Are there alternatives to this package for PostgreSQL support in Laravel?
If you're using Eloquent, consider `spatie/laravel-postgres` for basic PostgreSQL features or `beberlei/doctrineextensions` for Doctrine-specific enhancements. For full PostgreSQL support in Doctrine, this package is the most comprehensive, but alternatives like `doctrine/dbal` with raw SQL can work for simpler use cases.
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.
phalcon/cli-options-parser
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
directorytree/privacy-filter-classifier
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata