Skip to content

Commit fbd92eb

Browse files
DBAL v4, Middleware, Driver, Platform, and SchemaManager implementation (#61)
* Update DBAL to a minimum of 3.2 * DBAL middleware, driver, and extended platform * Migrate SchemaManager to extend DBAL's * Remove DBAL event subscriber & change ORM to listener * Add @Covers to generated Functions * Update existing tests and add new tests cover added classes * Update docs * Updates for DBAL v4 deprecations * Switch functions from Lexer constants to TokenType enum * Update minimum required versions * Update psalm baseline * Check platform option exists before use * Update docs * Raise Docker PHP version to 8.2 * feat: add doctrine/orm <2.18 in conflict * feat: csfixer * feat: rework filtered spatial indexes * feat: rework platform & schema manager * fix: prevent BC --------- Co-authored-by: Maxime Hélias <[email protected]>
1 parent 3dac231 commit fbd92eb

File tree

329 files changed

+3012
-3128
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

329 files changed

+3012
-3128
lines changed

README.md

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ Supported Versions
2525
The following table shows the versions which are officially supported by this
2626
library.
2727

28-
| Dependency | Supported Versions |
29-
|:--------------|:--------------------|
30-
| PostGIS | 3.0 and 3.1 |
31-
| PostgreSQL | 11, 12 and 13 |
32-
| Doctrine ORM | ^2.9 |
33-
| Doctrine DBAL | ^2.13 and ^3.1 |
28+
| Dependency | Supported Versions |
29+
|:--------------|:-------------------|
30+
| PostGIS | 3.0 and 3.1 |
31+
| PostgreSQL | 11, 12 and 13 |
32+
| Doctrine ORM | ^2.19 and ^3.0 |
33+
| Doctrine DBAL | ^3.7 and ^4.0 |
3434

3535
Installation
3636
--
@@ -47,23 +47,38 @@ for all available versions.
4747
Setup
4848
--
4949

50-
To use the library with the Doctrine ORM, register the
51-
`ORMSchemaEventSubscriber` event subscriber.
50+
Basic setup requires registering Middleware and the SchemaManagerFactory via the
51+
DBAL connection configuration.
5252

5353
```php
54-
use Jsor\Doctrine\PostGIS\Event\ORMSchemaEventSubscriber;
55-
56-
$entityManager->getEventManager()->addEventSubscriber(new ORMSchemaEventSubscriber());
54+
use Doctrine\DBAL\Configuration;
55+
use Doctrine\DBAL\Connection;
56+
use Doctrine\DBAL\Driver\PgSQL\Driver;
57+
use Jsor\Doctrine\PostGIS\Driver\Middleware;
58+
use Jsor\Doctrine\PostGIS\Event\ORMSchemaEventListener;
59+
use Jsor\Doctrine\PostGIS\Schema\SchemaManagerFactory;
60+
61+
$params = [
62+
// your connection parameters …
63+
];
64+
$config = new Configuration();
65+
$config->setMiddlewares([new Middleware]);
66+
$config->setSchemaManagerFactory(new SchemaManagerFactory());
67+
68+
$connection = new Connection($params, new Driver(), $config);
5769
```
5870

59-
To use it with the DBAL only, register the `DBALSchemaEventSubscriber` event
60-
subscriber.
71+
72+
Additionally, to also use the library with the Doctrine ORM, register the
73+
`ORMSchemaEventListener` event subscriber.
6174

6275
```php
63-
use Jsor\Doctrine\PostGIS\Event\DBALSchemaEventSubscriber;
76+
use Doctrine\ORM\Tools\ToolEvents;
77+
use Jsor\Doctrine\PostGIS\Event\ORMSchemaEventListener;
6478

65-
$connection->getEventManager()->addEventSubscriber(new DBALSchemaEventSubscriber());
79+
$entityManager->getEventManager()->addEventListener(ToolEvents::postGenerateSchemaTable, new ORMSchemaEventListener());
6680
```
81+
6782
### Symfony
6883

6984
For integrating this library into a Symfony project, read the dedicated

composer.json

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,21 @@
2222
}
2323
],
2424
"require": {
25-
"php": "^8.0",
26-
"doctrine/dbal": "^2.13 || ^3.1"
25+
"php": "^8.1",
26+
"doctrine/dbal": "^3.7 || ^4.0",
27+
"doctrine/deprecations": "^0.5.3 || ^1.0"
2728
},
2829
"require-dev": {
29-
"doctrine/orm": "^2.9",
30+
"doctrine/collections": "^2.0 || ^3.0",
31+
"doctrine/orm": "^2.19 || ^3.0",
3032
"friendsofphp/php-cs-fixer": "^3.13",
31-
"phpunit/phpunit": "^9.5",
33+
"phpunit/phpunit": "^9.6",
3234
"vimeo/psalm": "^5.9",
33-
"symfony/doctrine-bridge": "^5.4 || ^6.0",
34-
"symfony/doctrine-messenger": "^5.4 || ^6.0"
35+
"symfony/doctrine-bridge": "^6.4",
36+
"symfony/doctrine-messenger": "^6.4"
37+
},
38+
"conflict": {
39+
"doctrine/orm": "<2.18"
3540
},
3641
"suggest": {
3742
"doctrine/orm": "For using with the Doctrine ORM"

docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM php:8.1-cli-alpine AS php
1+
FROM php:8.2-cli-alpine AS php
22

33
RUN apk add --no-cache \
44
git \

docs/symfony.md

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,15 @@ Setup
1313

1414
To use the library with the Doctrine ORM (version 2.9 or higher is supported),
1515
register a [Doctrine event subscriber](https://symfony.com/doc/current/doctrine/event_listeners_subscribers.html)
16-
in `config/services.yml`.
16+
in `config/packages/jsor_doctrine_postgis.yaml`.
1717

1818
```yaml
1919
services:
20-
Jsor\Doctrine\PostGIS\Event\ORMSchemaEventSubscriber:
21-
tags:
22-
- { name: doctrine.event_subscriber, connection: default }
23-
```
24-
25-
The library can also be used with DBAL only (versions 2.13 or higher and 3.1 or
26-
higher are supported).
20+
Jsor\Doctrine\PostGIS\Event\ORMSchemaEventListener:
21+
tags: [{ name: doctrine.event_listener, event: postGenerateSchemaTable, connection: default }]
2722

28-
```yaml
29-
services:
30-
Jsor\Doctrine\PostGIS\Event\DBALSchemaEventSubscriber:
31-
tags:
32-
- { name: doctrine.event_subscriber, connection: default }
23+
Jsor\Doctrine\PostGIS\Driver\Middleware:
24+
tags: [ doctrine.middleware ]
3325
```
3426
3527
### Database Types
@@ -50,6 +42,10 @@ doctrine:
5042
commented: false
5143
```
5244

45+
> **Note:** The PostgreSQL native `geometry` and `geography` types are automatically
46+
> mapped to Doctrine types during schema introspection. You don't need to add them
47+
> to the `mapping_types` section.
48+
5349
### DQL Functions
5450

5551
To use the DQL functions provided by this library, they must be configured in

0 commit comments

Comments
 (0)