Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DBAL v4, Middleware, Driver, Platform, and SchemaManager implementation #61

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
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
  •  
  •  
  •  
33 changes: 24 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 6 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,16 @@
],
"require": {
"php": "^8.0",
"doctrine/dbal": "^2.13 || ^3.1"
"doctrine/dbal": "^3.7 || ^4.0"
},
"require-dev": {
"doctrine/orm": "^2.9",
"doctrine/collections": "^2.0 || ^3.0",
"doctrine/orm": "^2.19 || ^3.0",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should add a conflict like : "doctrine/orm": "<2.18" for Doctrine\ORM\Query\TokenType

"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"
},
"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: 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
Loading