martin-georgiev/postgresql-for-doctrine
最新稳定版本:v4.0.0
Composer 安装命令:
composer require 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.
关键字:
README 文档
README
PostgreSQL for Doctrine
Enhances Doctrine with PostgreSQL-specific features and functions. Supports PostgreSQL 9.4+ and PHP 8.2+.
Quick Start
use MartinGeorgiev\Doctrine\DBAL\Type; // Register types with Doctrine Type::addType(Type::JSONB, "MartinGeorgiev\\Doctrine\\DBAL\\Types\\Jsonb"); Type::addType(Type::TEXT_ARRAY, "MartinGeorgiev\\Doctrine\\DBAL\\Types\\TextArray"); Type::addType(Type::NUMRANGE, "MartinGeorgiev\\Doctrine\\DBAL\\Types\\NumRange"); // Use in your Doctrine entities #[ORM\Column(type: Type::JSONB)] private array $data; #[ORM\Column(type: Type::TEXT_ARRAY)] private array $tags; #[ORM\Column(type: Type::NUMRANGE)] private NumericRange $priceRange; // 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[]) - Float arrays (
real[],double precision[]) - Text arrays (
text[]) - Boolean arrays (
bool[]) - JSONB arrays (
jsonb[])
- Integer arrays (
- JSON Types
- Native JSONB support
- JSON field operations
- JSON construction and manipulation
- Network Types
- IP addresses (
inet,inet[]) - Network CIDR notation (
cidr,cidr[]) - MAC addresses (
macaddr,macaddr[])
- IP addresses (
- Geometric Types
- Point (
point,point[]) - PostGIS Geometry (
geometry,geometry[]) - PostGIS Geography (
geography,geography[])
- Point (
- Range Types
- Date and time ranges (
daterange,tsrange,tstzrange) - Numeric ranges (
numrange,int4range,int8range)
- Date and time ranges (
- Hierarchical Types
- ltree (
ltree)
- ltree (
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 (
- Range Operations
- Containment checks (in PHP value objects and for DQL queries with
@>and<@) - Overlaps (
&&)
- Containment checks (in PHP value objects and for DQL queries with
- PostGIS Spatial Operations
- Bounding box relationships (
<<,>>,&<,&>,|&>,&<|,<<|,|>>) - Spatial containment (
@,~) - Distance calculations (
<->,<#>,<<->>,<<#>>,|=|) - N-dimensional operations (
&&&)
- Bounding box relationships (
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_remove,array_replace,array_shuffle) - 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
- Aggregation with ordering and distinct (
array_agg,json_agg,jsonb_agg) - Special aggregates (
any_value,xmlagg)
- Aggregation with ordering and distinct (
- Mathematical/Arithmetic Functions
- Range Functions
- Data Type Formatting Functions
Full documentation:
- Available Types
- Value Objects for Range Types
- Available Functions and Operators - Overview and cross-references
- Common Use Cases and Examples
- Spatial Types
- Geometry Arrays
???? Installation
composer require martin-georgiev/postgresql-for-doctrine
???? Integration Guides
???? Usage Examples
See our Common Use Cases and Examples for detailed code samples.
See our ltree type usage guide for an example of how to use the ltree type.
???? Testing
Unit Tests
composer run-unit-tests
PostgreSQL Integration Tests
We also provide integration tests that run against a real PostgreSQL database with PostGIS to ensure compatibility:
# Start PostgreSQL with PostGIS using Docker Compose docker-compose up -d # Run integration tests composer run-integration-tests # Stop PostgreSQL docker-compose down -v
See tests/Integration/README.md for more details.
⭐ 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.
martin-georgiev/postgresql-for-doctrine 适用场景与选型建议
martin-georgiev/postgresql-for-doctrine 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.8M 次下载、GitHub Stars 达 438, 最近一次更新时间为 2026 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「dbal」 「json」 「doctrine」 「postgresql」 「postgres」 「jsonb」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 martin-georgiev/postgresql-for-doctrine 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 martin-georgiev/postgresql-for-doctrine 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 martin-georgiev/postgresql-for-doctrine 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Dibi is Database Abstraction Library for PHP
Kinikit - PHP Application development framework MVC component
ext-json wrapper with sane defaults
A custom Doctine DBAL type to use PHP DateTime objects set to the system's default timezone.
A package to cast json fields, each sub-keys is castable
Make pimcore migration simple
统计信息
- 总下载量: 4.8M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 443
- 点击次数: 33
- 依赖项目数: 5
- 推荐数: 1
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-04