Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
45 changes: 30 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ Supported Versions
The following table shows the versions which are officially supported by this
library.

| Dependency | Supported Versions |
|:--------------|:--------------------|
| PostGIS | 3.0 and 3.1 |
| PostgreSQL | 11, 12 and 13 |
| Doctrine ORM | ^2.9 |
| Doctrine DBAL | ^2.13 and ^3.1 |
| Dependency | Supported Versions |
|:--------------|:-------------------|
| PostGIS | 3.0 and 3.1 |
| PostgreSQL | 11, 12 and 13 |
| Doctrine ORM | ^2.19 and ^3.0 |
| Doctrine DBAL | ^3.7 and ^4.0 |

Installation
--
Expand All @@ -47,23 +47,38 @@ for all available versions.
Setup
--

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

```php
use Jsor\Doctrine\PostGIS\Event\ORMSchemaEventSubscriber;

$entityManager->getEventManager()->addEventSubscriber(new ORMSchemaEventSubscriber());
use Doctrine\DBAL\Configuration;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver\PgSQL\Driver;
use Jsor\Doctrine\PostGIS\Driver\Middleware;
use Jsor\Doctrine\PostGIS\Event\ORMSchemaEventListener;
use Jsor\Doctrine\PostGIS\Schema\SchemaManagerFactory;

$params = [
// your connection parameters …
];
$config = new Configuration();
$config->setMiddlewares([new Middleware]);
$config->setSchemaManagerFactory(new SchemaManagerFactory());

$connection = new Connection($params, new Driver(), $config);
```

To use it with the DBAL only, register the `DBALSchemaEventSubscriber` event
subscriber.

Additionally, to also use the library with the Doctrine ORM, register the
`ORMSchemaEventListener` event subscriber.

```php
use Jsor\Doctrine\PostGIS\Event\DBALSchemaEventSubscriber;
use Doctrine\ORM\Tools\ToolEvents;
use Jsor\Doctrine\PostGIS\Event\ORMSchemaEventListener;

$connection->getEventManager()->addEventSubscriber(new DBALSchemaEventSubscriber());
$entityManager->getEventManager()->addEventListener(ToolEvents::postGenerateSchemaTable, new ORMSchemaEventListener());
```

### Symfony

For integrating this library into a Symfony project, read the dedicated
Expand Down
17 changes: 11 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,21 @@
}
],
"require": {
"php": "^8.0",
"doctrine/dbal": "^2.13 || ^3.1"
"php": "^8.1",
"doctrine/dbal": "^3.7 || ^4.0",
"doctrine/deprecations": "^0.5.3 || ^1.0"
},
"require-dev": {
"doctrine/orm": "^2.9",
"doctrine/collections": "^2.0 || ^3.0",
"doctrine/orm": "^2.19 || ^3.0",
"friendsofphp/php-cs-fixer": "^3.13",
"phpunit/phpunit": "^9.5",
"phpunit/phpunit": "^9.6",
"vimeo/psalm": "^5.9",
"symfony/doctrine-bridge": "^5.4 || ^6.0",
"symfony/doctrine-messenger": "^5.4 || ^6.0"
"symfony/doctrine-bridge": "^6.4",
"symfony/doctrine-messenger": "^6.4"
},
"conflict": {
"doctrine/orm": "<2.18"
},
"suggest": {
"doctrine/orm": "For using with the Doctrine ORM"
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:8.1-cli-alpine AS php
FROM php:8.2-cli-alpine AS php

RUN apk add --no-cache \
git \
Expand Down
22 changes: 9 additions & 13 deletions docs/symfony.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,15 @@ Setup

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

```yaml
services:
Jsor\Doctrine\PostGIS\Event\ORMSchemaEventSubscriber:
tags:
- { name: doctrine.event_subscriber, connection: default }
```

The library can also be used with DBAL only (versions 2.13 or higher and 3.1 or
higher are supported).
Jsor\Doctrine\PostGIS\Event\ORMSchemaEventListener:
tags: [{ name: doctrine.event_listener, event: postGenerateSchemaTable, connection: default }]

```yaml
services:
Jsor\Doctrine\PostGIS\Event\DBALSchemaEventSubscriber:
tags:
- { name: doctrine.event_subscriber, connection: default }
Jsor\Doctrine\PostGIS\Driver\Middleware:
tags: [ doctrine.middleware ]
```

### Database Types
Expand All @@ -50,6 +42,10 @@ doctrine:
commented: false
```

> **Note:** The PostgreSQL native `geometry` and `geography` types are automatically
> mapped to Doctrine types during schema introspection. You don't need to add them
> to the `mapping_types` section.

### DQL Functions

To use the DQL functions provided by this library, they must be configured in
Expand Down
Loading