Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
GwendolenLynch committed Jul 1, 2023
1 parent 1d66778 commit 7c34d2b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 19 deletions.
28 changes: 21 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,37 @@ 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 Doctrine\DBAL\Configuration;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver\PgSQL\Driver;
use Jsor\Doctrine\PostGIS\Driver\Middleware;
use Jsor\Doctrine\PostGIS\Event\ORMSchemaEventSubscriber;
use Jsor\Doctrine\PostGIS\Schema\SchemaManagerFactory;

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

$connection->getEventManager()->addEventSubscriber(new DBALSchemaEventSubscriber());
$entityManager->getEventManager()->addEventSubscriber(new ORMSchemaEventSubscriber());
```

### Symfony

For integrating this library into a Symfony project, read the dedicated
Expand Down
22 changes: 10 additions & 12 deletions docs/symfony.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,21 @@ 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 }
```
Jsor\Doctrine\PostGIS\Schema\SchemaManagerFactory:

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 ]

doctrine:
dbal:
schema_manager_factory: Jsor\Doctrine\PostGIS\Schema\SchemaManagerFactory
```
### Database Types
Expand Down

0 comments on commit 7c34d2b

Please sign in to comment.