|
2 | 2 | [](https://coveralls.io/github/martin-georgiev/postgresql-for-doctrine?branch=main) |
3 | 3 | [](https://packagist.org/packages/martin-georgiev/postgresql-for-doctrine) |
4 | 4 | [](https://packagist.org/packages/martin-georgiev/postgresql-for-doctrine) |
5 | | ----- |
6 | | -## What's this? |
7 | | -This package provides Doctrine support for some specific PostgreSQL 9.4+ features: |
8 | 5 |
|
9 | | -* Support of JSONB and some array data-types (at present integers, BOOL, TEXT and JSONB) |
10 | | -* Implementation of the most commonly used functions and operators when working with array and JSON data-types |
11 | | -* Functions for text search |
12 | | -* Aggregate functions |
13 | | -* Date functions |
| 6 | +# PostgreSQL for Doctrine |
14 | 7 |
|
15 | | -It can be integrated in a simple manner with Symfony, Laravel and other frameworks that make use of Doctrine. |
| 8 | +Enhances Doctrine with PostgreSQL-specific features and functions. Supports PostgreSQL 9.4+ and PHP 8.1+. |
16 | 9 |
|
17 | | -You can easily extend package's behaviour with your own array-like data-types or other desired functions. Read more about this in the [contributing guide](docs/CONTRIBUTING.md). |
| 10 | +## Quick Start |
18 | 11 |
|
19 | | ----- |
20 | | -## What is available? |
21 | | -Full set of the available types can be found [here](docs/AVAILABLE-TYPES.md). |
| 12 | +```php |
| 13 | +// Register types with Doctrine |
| 14 | +Type::addType('jsonb', "MartinGeorgiev\\Doctrine\\DBAL\\Types\\Jsonb"); |
| 15 | +Type::addType('text[]', "MartinGeorgiev\\Doctrine\\DBAL\\Types\\TextArray"); |
22 | 16 |
|
23 | | -Full set of the available functions and extra operators can be found [here](docs/AVAILABLE-FUNCTIONS-AND-OPERATORS.md). |
| 17 | +// Use in your Doctrine entities |
| 18 | +#[ORM\Column(type: 'jsonb')] |
| 19 | +private array $data; |
24 | 20 |
|
25 | | ----- |
26 | | -## How to install? |
27 | | -Easiest and recommended way is with [Composer](https://getcomposer.org/download/) |
| 21 | +#[ORM\Column(type: 'text[]')] |
| 22 | +private array $tags; |
28 | 23 |
|
29 | | - composer require martin-georgiev/postgresql-for-doctrine |
| 24 | +// Use in DQL |
| 25 | +$query = $em->createQuery(' |
| 26 | + SELECT e |
| 27 | + FROM App\Entity\Post e |
| 28 | + WHERE CONTAINS(e.tags, ARRAY[:tags]) = TRUE |
| 29 | + AND JSON_GET_FIELD(e.data, :field) = :value |
| 30 | +'); |
| 31 | +``` |
30 | 32 |
|
31 | | ----- |
32 | | -## How to integrate with your framework? |
33 | | -Read the guide with examples for [Symfony](docs/INTEGRATING-WITH-SYMFONY.md). |
| 33 | +## 🚀 Features Highlight |
34 | 34 |
|
35 | | -Read the guide with examples for [Laravel](docs/INTEGRATING-WITH-LARAVEL.md). |
| 35 | +This package provides comprehensive Doctrine support for PostgreSQL features: |
36 | 36 |
|
37 | | -Read the guide with examples for [Doctrine](docs/INTEGRATING-WITH-DOCTRINE.md). |
| 37 | +### Data Types |
| 38 | +- **Array Types** |
| 39 | + - Integer arrays (`int[]`, `smallint[]`, `bigint[]`) |
| 40 | + - Text arrays (`text[]`) |
| 41 | + - Boolean arrays (`bool[]`) |
| 42 | + - JSONB arrays (`jsonb[]`) |
| 43 | +- **JSON Types** |
| 44 | + - Native JSONB support |
| 45 | + - JSON field operations |
| 46 | + - JSON construction and manipulation |
38 | 47 |
|
39 | | ----- |
| 48 | +### PostgreSQL Operators |
| 49 | +- **Array Operations** |
| 50 | + - Contains (`@>`) |
| 51 | + - Is contained by (`<@`) |
| 52 | + - Overlaps (`&&`) |
| 53 | + - Array aggregation with ordering |
| 54 | +- **JSON Operations** |
| 55 | + - Field access (`->`, `->>`) |
| 56 | + - Path operations (`#>`, `#>>`) |
| 57 | + - JSON containment and existence operators |
40 | 58 |
|
41 | | -Check for [common use-cases, examples and known errors](docs/USE-CASES-AND-EXAMPLES.md). |
| 59 | +### Functions |
| 60 | +- **Text Search** |
| 61 | + - Full text search (`to_tsvector`, `to_tsquery`) |
| 62 | + - Pattern matching (`ILIKE`, `SIMILAR TO`) |
| 63 | + - Regular expressions |
| 64 | +- **Array Functions** |
| 65 | + - Array aggregation (`array_agg`) |
| 66 | + - Array manipulation (`array_append`, `array_prepend`) |
| 67 | + - Array dimensions and length |
| 68 | +- **JSON Functions** |
| 69 | + - JSON construction (`json_build_object`, `jsonb_build_object`) |
| 70 | + - JSON manipulation and transformation |
| 71 | +- **Date Functions** |
| 72 | +- **Aggregate Functions** |
42 | 73 |
|
43 | | ----- |
44 | | -## License |
45 | | -This package is licensed under the MIT License. |
| 74 | +Full documentation: |
| 75 | +- [Available Types](docs/AVAILABLE-TYPES.md) |
| 76 | +- [Available Functions and Operators](docs/AVAILABLE-FUNCTIONS-AND-OPERATORS.md) |
| 77 | +- [Common Use Cases and Examples](docs/USE-CASES-AND-EXAMPLES.md) |
| 78 | + |
| 79 | +## 📦 Installation |
| 80 | + |
| 81 | +```bash |
| 82 | +composer require martin-georgiev/postgresql-for-doctrine |
| 83 | +``` |
| 84 | + |
| 85 | +## 🔧 Integration Guides |
| 86 | + |
| 87 | +- [Integrating with Symfony](docs/INTEGRATING-WITH-SYMFONY.md) |
| 88 | +- [Integrating with Laravel](docs/INTEGRATING-WITH-LARAVEL.md) |
| 89 | +- [Integrating with Doctrine](docs/INTEGRATING-WITH-DOCTRINE.md) |
| 90 | + |
| 91 | +## 💡 Usage Examples |
| 92 | +See our [Common Use Cases and Examples](docs/USE-CASES-AND-EXAMPLES.md) for detailed code samples. |
| 93 | + |
| 94 | +## ⭐ Support the Project |
| 95 | + |
| 96 | +### 💖 GitHub Sponsors |
| 97 | +If you find this package useful for your projects, please consider [sponsoring the development via GitHub Sponsors](https://github.com/sponsors/martin-georgiev). Your support helps maintain this package, create new features, and improve documentation. |
| 98 | + |
| 99 | +Benefits of sponsoring: |
| 100 | +- Priority support for issues and feature requests |
| 101 | +- Direct access to the maintainer |
| 102 | +- Help sustain open-source development |
| 103 | + |
| 104 | +### Other Ways to Help |
| 105 | +- Star the repository |
| 106 | +- [Report issues](https://github.com/martin-georgiev/postgresql-for-doctrine/issues) |
| 107 | +- [Contribute](docs/CONTRIBUTING.md) with code or documentation |
| 108 | +- Share the project with others |
| 109 | + |
| 110 | +## 📝 License |
| 111 | +This package is licensed under the MIT License. See the [LICENSE](LICENSE) file for details. |
0 commit comments