doctrine / DoctrineMongoDBBundle

Integrates Doctrine MongoDB ODM with Symfony
http://symfony.com/doc/current/bundles/DoctrineMongoDBBundle/index.html
MIT License
379 stars 229 forks source link

Add support for detecting bundle mapping with the new bundle structure #713

Closed mbabker closed 2 years ago

mbabker commented 2 years ago

Companion PR to https://github.com/symfony/symfony/pull/43181

This adds support for detecting bundle mapping if a bundle is using the newer directory structure.

malarzm commented 2 years ago

@mbabker thanks for the PR!

This adds support for detecting bundle mapping if a bundle is using the newer directory structure.

Could you please link what the newer directory structure looks like? I tried googling but to no avail, from the PR I guess that Resources folder is being ditched?

If above is true we have some references in the docs that mapping files should be put in Resources/config/doctrine/ directory (for instance https://www.doctrine-project.org/projects/doctrine-mongodb-bundle/en/4.3/config.html#mapping-configuration). Could you please write some note that it now varies basing on Symfony's version?

mbabker commented 2 years ago

Could you please link what the newer directory structure looks like? I tried googling but to no avail, from the PR I guess that Resources folder is being ditched?

Pretty much the same as a Flex application's structure, see https://symfony.com/doc/current/bundles/best_practices.html#directory-structure

If above is true we have some references in the docs that mapping files should be put in Resources/config/doctrine/ directory (for instance https://www.doctrine-project.org/projects/doctrine-mongodb-bundle/en/4.3/config.html#mapping-configuration). Could you please write some note that it now varies basing on Symfony's version?

It's not entirely Symfony version dependent, it's pretty much 100% bundle dependent. Symfony itself supports the newer root structure since 4.4, but admittedly I haven't seen it used on too many bundles yet (I'm using it on branches I've dropped Symfony 3.4 support because I do think it's a bit cleaner, but that's a subjective opinion at best), and I can't say I've seen anything that implies that the older structure with the Resources folder that everyone knows will be going away anytime soon.

The gist of it though is that for bundles, if you use the structure recommended in the best practices guide, when a combination of the Doctrine Bridge PR and the Doctrine bundle PR(s) (both here and the ORM) relevant to your bundle land, and your minimum versions support these PRs, then you can put your mapping files in config/doctrine and they'd be automatically picked up the same way that they are from Resources/config/doctrine now. If you're crazy enough to live on the edge and use the newer structure AND want to put the files in config/doctrine, you can do it now, but you have to deal with the path registration on your own (see https://github.com/BabDev/MoneyBundle/blob/1.x/src/BabDevMoneyBundle.php for an example).

malarzm commented 2 years ago

Thanks for the explanation :) I still think the docs could be updated to reflect that config/doctrine will be automatically picked up if possible (and using one or another is up to user's taste)

franmomu commented 2 years ago

~The failing tests are not related to this PR, I think they will be fixed with https://github.com/doctrine/DoctrineMongoDBBundle/pull/714, can you please add those changes here to have the CI build green? everything else~ LGTM.

franmomu commented 2 years ago

Restarting the build

malarzm commented 2 years ago

Thanks a lot @mbabker!