- 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.