Skip to content

Commit 1b766d0

Browse files
Update docs
1 parent 12dbb6b commit 1b766d0

File tree

2 files changed

+31
-19
lines changed

2 files changed

+31
-19
lines changed

README.md

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,23 +47,37 @@ 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 Doctrine\DBAL\Configuration;
55+
use Doctrine\DBAL\Connection;
56+
use Doctrine\DBAL\Driver\PgSQL\Driver;
57+
use Jsor\Doctrine\PostGIS\Driver\Middleware;
5458
use Jsor\Doctrine\PostGIS\Event\ORMSchemaEventSubscriber;
59+
use Jsor\Doctrine\PostGIS\Schema\SchemaManagerFactory;
5560

56-
$entityManager->getEventManager()->addEventSubscriber(new ORMSchemaEventSubscriber());
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 Jsor\Doctrine\PostGIS\Event\ORMSchemaEventListener;
6477

65-
$connection->getEventManager()->addEventSubscriber(new DBALSchemaEventSubscriber());
78+
$entityManager->getEventManager()->addEventSubscriber(new ORMSchemaEventSubscriber());
6679
```
80+
6781
### Symfony
6882

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

docs/symfony.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,21 @@ 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-
```
20+
Jsor\Doctrine\PostGIS\Schema\SchemaManagerFactory:
2421

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

28-
```yaml
29-
services:
30-
Jsor\Doctrine\PostGIS\Event\DBALSchemaEventSubscriber:
31-
tags:
32-
- { name: doctrine.event_subscriber, connection: default }
25+
Jsor\Doctrine\PostGIS\Driver\Middleware:
26+
tags: [ doctrine.middleware ]
27+
28+
doctrine:
29+
dbal:
30+
schema_manager_factory: Jsor\Doctrine\PostGIS\Schema\SchemaManagerFactory
3331
```
3432
3533
### Database Types

0 commit comments

Comments
 (0)