martin-georgiev / postgresql-for-doctrine
Adds PostgreSQL enhancements to Doctrine. Provides support for JSON, JSONB and some array data types. Provides functions, operators and common expressions used when working with JSON data, arrays and features related to text search.
Fund package maintenance!
martin-georgiev
github.com/sponsors/martin-georgiev
Installs: 3 577 259
Dependents: 4
Suggesters: 1
Security: 0
Stars: 396
Watchers: 10
Forks: 48
Open Issues: 18
Requires
- php: ^8.1
- ext-ctype: *
- ext-json: *
- ext-mbstring: *
- doctrine/dbal: ~2.10||~3.0||~4.0
Requires (Dev)
- deptrac/deptrac: ^3.0
- doctrine/orm: ~2.14||~3.0
- ekino/phpstan-banned-code: ^3.0
- friendsofphp/php-cs-fixer: ^3.73.1
- phpstan/phpstan: ^2.1.8
- phpstan/phpstan-deprecation-rules: ^2.0.1
- phpstan/phpstan-doctrine: ^2.0.2
- phpstan/phpstan-phpunit: ^2.0.4
- phpunit/phpunit: ^10.5.45
- rector/rector: ^2.0.10
- symfony/cache: ^6.4||^7.0
Suggests
- php: ^8.3
- doctrine/orm: ~2.14||~3.0
- dev-main
- v2.10.3
- v2.10.2
- v2.10.1
- v2.10.0
- v2.9.0
- v2.8.0
- v2.7.0
- v2.6.0
- v2.5.0
- v2.4.1
- v2.4.0
- v2.3.2
- v2.3.1
- v2.3.0
- v2.2.0
- v2.1.2
- v2.1.1
- v2.1.0
- v2.0.1
- v2.0.0
- v1.8.0
- v1.7.0
- v1.6.0
- v1.5.3
- v1.5.2
- v1.5.1
- v1.5.0
- v1.4.1
- v1.4.0
- v1.3.0
- v1.2.2
- v1.2.1
- v1.2
- v1.1
- v1.0.1
- v1.0
- v0.12
- v0.11
- 0.10
- 0.9
- 0.8.1
- 0.8
- 0.7
- 0.6.2
- 0.6.1
- 0.6
- 0.5
- 0.4
- 0.3
- 0.2
- 0.1.1
- 0.1
- dev-release-please--branches--main
- dev-distinct-support
- dev-skip-auto-review-for-owner
- dev-do-not-ci-when-not-needed
- dev-run-test-coverage-only-on-latest
- dev-sloth
- dev-jsonbarrexceptions
- dev-network-types
- dev-dropphp81
This package is auto-updated.
Last update: 2025-03-28 19:42:24 UTC
README
PostgreSQL for Doctrine
Enhances Doctrine with PostgreSQL-specific features and functions. Supports PostgreSQL 9.4+ and PHP 8.1+.
Quick Start
// Register types with Doctrine Type::addType('jsonb', "MartinGeorgiev\\Doctrine\\DBAL\\Types\\Jsonb"); Type::addType('text[]', "MartinGeorgiev\\Doctrine\\DBAL\\Types\\TextArray"); // Use in your Doctrine entities #[ORM\Column(type: 'jsonb')] private array $data; #[ORM\Column(type: 'text[]')] private array $tags; // Use in DQL $query = $em->createQuery(' SELECT e FROM App\Entity\Post e WHERE CONTAINS(e.tags, ARRAY[:tags]) = TRUE AND JSON_GET_FIELD(e.data, :field) = :value ');
🚀 Features Highlight
This package provides comprehensive Doctrine support for PostgreSQL features:
Data Types
- Array Types
- Integer arrays (
int[]
,smallint[]
,bigint[]
) - Text arrays (
text[]
) - Boolean arrays (
bool[]
) - JSONB arrays (
jsonb[]
)
- Integer arrays (
- JSON Types
- Native JSONB support
- JSON field operations
- JSON construction and manipulation
PostgreSQL Operators
- Array Operations
- Contains (
@>
) - Is contained by (
<@
) - Overlaps (
&&
) - Array aggregation with ordering
- Contains (
- JSON Operations
- Field access (
->
,->>
) - Path operations (
#>
,#>>
) - JSON containment and existence operators
- Field access (
Functions
- Text Search
- Full text search (
to_tsvector
,to_tsquery
) - Pattern matching (
ILIKE
,SIMILAR TO
) - Regular expressions
- Full text search (
- Array Functions
- Array aggregation (
array_agg
) - Array manipulation (
array_append
,array_prepend
) - Array dimensions and length
- Array aggregation (
- JSON Functions
- JSON construction (
json_build_object
,jsonb_build_object
) - JSON manipulation and transformation
- JSON construction (
- Date Functions
- Aggregate Functions
Full documentation:
📦 Installation
composer require martin-georgiev/postgresql-for-doctrine
🔧 Integration Guides
💡 Usage Examples
See our Common Use Cases and Examples for detailed code samples.
⭐ Support the Project
💖 GitHub Sponsors
If you find this package useful for your projects, please consider sponsoring the development via GitHub Sponsors. Your support helps maintain this package, create new features, and improve documentation.
Benefits of sponsoring:
- Priority support for issues and feature requests
- Direct access to the maintainer
- Help sustain open-source development
Other Ways to Help
- Star the repository
- Report issues
- Contribute with code or documentation
- Share the project with others
📝 License
This package is licensed under the MIT License. See the LICENSE file for details.