From 1b766d0a1ab3b51018beb624dc78b81eb5716eff Mon Sep 17 00:00:00 2001 From: Gwendolen Lynch Date: Sat, 1 Jul 2023 18:35:32 +0200 Subject: [PATCH] Update docs --- README.md | 28 +++++++++++++++++++++------- docs/symfony.md | 22 ++++++++++------------ 2 files changed, 31 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index c7fd6415..a9d05488 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/docs/symfony.md b/docs/symfony.md index 6b0fd47d..a3eb38e1 100644 --- a/docs/symfony.md +++ b/docs/symfony.md @@ -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