doctrine / orm

Doctrine Object Relational Mapper (ORM)
https://www.doctrine-project.org/projects/orm.html
MIT License
9.86k stars 2.5k forks source link

Support `.orm{version}.xml` mapping #11388

Closed VincentLanglet closed 3 months ago

VincentLanglet commented 3 months ago

Feature Request

Q A
New Feature yes
RFC yes
BC Break no

Summary

I might be wrong but compatibility with both doctrine ORM 2 and ORM 3 is not easy for lib like SonataUserBundle which use xml configuration like https://github.com/sonata-project/SonataUserBundle/blob/5.x/src/Resources/config/doctrine/BaseUser.orm.xml

In this one the type array was removed in ORM 3, but changing the xml would be a BC break for ORM 2 user since it require a migration for the database.

What could be helpful would be the way to use a .orm3.xml file with the following logic:

Same logic could be done for other major versions, if doctrine finds a Foo.orm{majorVersion}.xml and a Foo.orm.xml file it prefers the Foo.orm{majorVersion}.xml with the right majorVersion.

Fedik commented 3 months ago

You already can use custom extension https://github.com/doctrine/orm/blob/55c4845d5734bea5579424c2c2a7c5b97dbb4c60/src/Mapping/Driver/XmlDriver.php#L44-L52

Following should work, in theory:

$v2 = new XmlDriver($locator, '.orm2.xml');
$v3 = new XmlDriver($locator, '.orm3.xml');
VincentLanglet commented 3 months ago

Yes, but I didn't find any occurence of XmlDriver in the library https://github.com/search?q=repo%3Asonata-project%2FSonataUserBundle%20XmlDriver&type=code

But after more thought, I think it's because it's automatically loaded by DoctrineOrmBundle. So the issue should maybe be open in https://github.com/doctrine/DoctrineBundle instead ?