doctrine-postgis icon indicating copy to clipboard operation
doctrine-postgis copied to clipboard

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

Open GwendolenLynch opened this issue 2 years ago • 10 comments

From DBAL 3.2 the events systems is (mostly?) deprecated in favour of middleware, and custom schema manager + factory combination.

The main purpose of this PR is to migrate as much as possible to this:

  • Jsor\Doctrine\PostGIS\Driver\Driver that extends AbstractPostgreSQLDriver
  • Jsor\Doctrine\PostGIS\Driver\Middleware that wraps the lower level Driver inside the PostGIS Driver
  • Jsor\Doctrine\PostGIS\Driver\PostGISPlatform wraps Doctrine\DBAL\Platforms\PostgreSQLPlatform and is instantiated by the PostGIS Driver
  • Jsor\Doctrine\PostGIS\Schema\SchemaManager now extends Doctrine\DBAL\Schema\PostgreSQLSchemaManager and handles schema management
  • Jsor\Doctrine\PostGIS\Schema\SchemaManagerFactory is an implementation of Doctrine\DBAL\Schema\SchemaManagerFactory
    • Creates the SchemaManager instance inside Connection
  • Functionality from Jsor\Doctrine\PostGIS\Event\DBALSchemaEventSubscriber moved to PostGISPlatform

Additionally:

  • Updated docs
  • Added @covers on most tests to get a better view of coverage
  • Updated tests and all pass
  • Updated psalm.xml and it passes

Bonus: It is now possible to extend Jsor\Doctrine\PostGIS\Types\GeographyType or Jsor\Doctrine\PostGIS\Types\GeometryType and not have the schema tool throw a tantrum. See PostGISPlatformTest

Feedback welcome, and I'm happy to add/adjust/drop relevant things.

Edit: Fixes #63

GwendolenLynch avatar Jul 01 '23 17:07 GwendolenLynch

@jsor we have been using this fork with no issues for a while now, any progress/help-needed here?

thePanz avatar Feb 20 '24 14:02 thePanz

This latest update should take care of the remaining deprecations to support DBAL v4 (and silence PHPUnit).

Tests are passing locally.

GwendolenLynch avatar Mar 07 '24 16:03 GwendolenLynch

:+1: This branch works for me, I was able to upgrade an existing symfony project to DBAL 4, ORM 3. Thanks!

wesnick avatar Mar 21 '24 12:03 wesnick

@GwendolenLynch in the documentation you write:

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

use Jsor\Doctrine\PostGIS\Event\ORMSchemaEventListener;

$entityManager->getEventManager()->addEventSubscriber(new ORMSchemaEventSubscriber());

In the example you register ORMSchemaEventSubscriber, if someone just copies it it will fail.

tasselchof avatar Apr 22 '24 20:04 tasselchof

Also, I am getting this when I am adding ORM subscriber:

PHP Fatal error:  Uncaught Roave\PsrContainerDoctrine\Exception\DomainException: Invalid event subscriber "Jsor\Doctrine\PostGIS\Event\ORMSchemaEventListener" given, must be a dependency name, class name or an instance implementing Doctrine\Common\EventSubscriber in /../vendor/roave/psr-container-doctrine/src/Exception/DomainException.php:36

tasselchof avatar Apr 22 '24 20:04 tasselchof

Thanks for your feedback, @tasselchof. I'm going to try to add some more tests to cover this.

What versions of doctrine/orm, doctrine/dbal, and doctrine/common are you using?

GwendolenLynch avatar Apr 23 '24 08:04 GwendolenLynch

Thanks for your feedback, @tasselchof. I'm going to try to add some more tests to cover this.

What versions of doctrine/orm, doctrine/dbal, and doctrine/common are you using?

I've made a pull request to your branch with those fixes: https://github.com/GwendolenLynch/doctrine-postgis/pull/1. You can merge it to fix those and if I will find anything else - I will do another pull request. It's just one test if you wish to add it.

[app]$ composer show doctrine/*
doctrine/annotations   2.0.1  Docblock Annotations Parser
doctrine/collections   2.2.2  PHP Doctrine Collections library that adds additional functionality on top of PHP arrays.
doctrine/common        3.4.4  PHP Doctrine Common project is a library that provides additional functionality that other Doctrine projects depend on such as better reflection sup...
doctrine/data-fixtures 1.7.0  Data Fixtures for all Doctrine Object Managers
doctrine/dbal          4.0.1  Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.
doctrine/deprecations  1.1.3  A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.
doctrine/event-manager 2.0.0  The Doctrine Event Manager is a simple PHP event system that was built to be used with the various Doctrine projects.
doctrine/inflector     2.0.10 PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upper/lowercase and singular/plural forms of words.
doctrine/instantiator  2.0.0  A small, lightweight utility to instantiate objects in PHP without invoking their constructors
doctrine/lexer         3.0.1  PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.
doctrine/migrations    3.7.4  PHP Doctrine Migrations project offer additional functionality on top of the database abstraction layer (DBAL) for versioning your database schema a...
doctrine/orm           3.1.2  Object-Relational-Mapper for PHP
doctrine/persistence   3.3.2  The Doctrine Persistence project is a set of shared interfaces and functionality that the different Doctrine object mappers share.

tasselchof avatar Apr 23 '24 09:04 tasselchof

Hey guys! Are there any plans on merging this or should we rollback to DBAL v3?

scripness avatar May 08 '24 12:05 scripness

Hello everyone, any news on this MR ? Are the changelog is the only thing missing for merging it ?

GErpeldinger avatar Jul 02 '24 09:07 GErpeldinger