承接 martin-georgiev/postgresql-for-doctrine 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

Scrutinizer Code Quality Coverage Status Latest Stable Version Total Downloads

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[])
  • 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[])
  • Geometric Types
    • Point (point, point[])
    • PostGIS Geometry (geometry, geometry[])
    • PostGIS Geography (geography, geography[])
  • Range Types
    • Date and time ranges (daterange, tsrange, tstzrange)
    • Numeric ranges (numrange, int4range, int8range)
  • Hierarchical Types

PostgreSQL Operators

  • Array Operations
    • Contains (@>)
    • Is contained by (<@)
    • Overlaps (&&)
    • Array aggregation with ordering
  • JSON Operations
    • Field access (->, ->>)
    • Path operations (#>, #>>)
    • JSON containment and existence operators
  • Range Operations
    • Containment checks (in PHP value objects and for DQL queries with @> and <@)
    • Overlaps (&&)
  • PostGIS Spatial Operations
    • Bounding box relationships (<<, >>, &<, &>, |&>, &<|, <<|, |>>)
    • Spatial containment (@, ~)
    • Distance calculations (<->, <#>, <<->>, <<#>>, |=|)
    • N-dimensional operations (&&&)

Functions

  • Text Search
    • Full text search (to_tsvector, to_tsquery)
    • Pattern matching (ilike, similar to)
    • Regular expressions
  • Array Functions
    • Array aggregation (array_agg)
    • Array manipulation (array_append, array_prepend, array_remove, array_replace, array_shuffle)
    • Array dimensions and length
  • JSON Functions
    • JSON construction (json_build_object, jsonb_build_object)
    • JSON manipulation and transformation
  • Date Functions
  • Aggregate Functions
    • Aggregation with ordering and distinct (array_agg, json_agg, jsonb_agg)
    • Special aggregates (any_value, xmlagg)
  • Mathematical/Arithmetic Functions
  • Range Functions
  • Data Type Formatting 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.

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

???? License

This package is licensed under the MIT License. See the LICENSE file for details.

统计信息

  • 总下载量: 4.8M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 443
  • 点击次数: 3
  • 依赖项目数: 5
  • 推荐数: 1

GitHub 信息

  • Stars: 438
  • Watchers: 9
  • Forks: 56
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04