Repository navigation
Replies: 4 comments 7 replies
The docs mention such a driver: https://www.doctrine-project.org/projects/doctrine-orm/en/3.6/reference/metadata-drivers.html#:~:text=PHPDriver There are more docs here. And also, you could write your own YamlDriver by copying code from ORM 2. |
Converting YAML files to XML shouldn't be too hard, actually. And ORM 2 should still ship tooling to do that.
Two teams, two different decisions, same motivation: Maintaining too many config formats is not worth the effort.
Well, you don't necessarily have to and it's not our recommendation either.
Yes. This is the way.
Which is not a problem unless you don't own those "domain objects".
Okay, but that's your decision.
Our metadata drivers are an extension point. You can provide your own if you really want to customize your configuration experience. But I wouldn't recommend to do that out of a distaste for XML.
That's the two flavors that we offer out of the box, yes. There's still the
Our strong advice is to use attributes. |
|
Thank you so much for your responses. I am aware of the clear recommendation of attributes but our system is special, the "entities" are ours, but kinda halfbaked separated, so back in time the architecture decision to account for DDD was that entities are plain (we only allow doctrine collection) everything else is mapped outside ontop of it and using attributes would break that. Since it's a huge project changing that, is overkill so the approach remains that the mapping is coming from outside. It a perfect worls, we would have doctrine entities with proper attributes and the domain objects separately and repository takes care of accepting domain object and turns into managed entity for persitence, but even with AI this would be insanity. That said, I found out about the static PHP driver and made an attempt to convert from YAML to that PHP mappings, but failed miserably. As pointed out documentation is limited and I weren't able to reach a state where php mappings 1:1 replaced the current YAML mappings. Maybe it would have worked when working with plain doctrine, but since it's paired with symfony I didn't found a working solution with them. The static php asks to add static methods on the object itself which is similar to attributes not an option, as it requires to import all the doctrine internals. So I tried it to do it somehow outside, but couldn't figure out how to make them be loaded... Also AI couldn't help with that. It might became better with better models, when I ask it to deeple analyze how it works internally, but as docs are so limited and probably almost no examples are outside there, it halluzinates too much to be helpful. Any chance you can guide me, how to approach it? |
|
Coming back after a long while, our project is mostly converted to XML now, actually I in parallel worked on conversion to PHP and it works. So it's possible to do it with PHP however, not only is it almost not covered by the docs on how to do it, but also tooling like the symfony plugin no longer discovers those mappings to you can switch between Enity class and Definition. Given that AI Agents had to dig the implementation to figure it out and the overall support is not really given and it's kinda wierd you sometimes need to use createField and sometimes addField (depending on wht you need, for example having differing name on the column name) we probably have to stick to XML. It remains, that I really wonder why this has such a low priority, as PHP would help not missing references on renaming and you would have usage support of modern IDEs. As it seems it's a second class citizen option, tooling never caught up and not sure if it ever will even if effort is spend on this. So I just accept XML is the only really usable option if you don't want to have infrastructure imports in your Entities living in your domain. Only other option would be to mirror them, have a pure infrastructure object with annotations and tansform to domain object back and forth, but this is for newer projects only. I learned a lot and it's interesting that this option works in theory, but I can't recommend anyone using this. |
Uh oh!
There was an error while loading. Please reload this page.
So, still working on preparing our legacy code that is using YAML to map on top of PHP objects in order to be ready for the newer version. We are kinda stuck on 2.x until we removed YAML. And this is really taking its time.
In AI era you can find your way through that. But it definitely hurts a little to convert this very well readable YAML format into that obfuscated and verbose XML format. And while I understand that the goal was to reduce the amount of supported config formats I find it funny that at nearly the same time Symfony decided to drop XML in favor of YAML to reduce the configuration formats... So this is... yeah something we might just have to accept. However what is actually boggling me even more is the fact that we now having to use XML as our only other option is attributes which is mixing like a pure php domain object with some doctrine imports. So we definitely want to have this outside and it's really sad that there's no other way like pure php configuration for that. It's either attributes or xml and that's it.
I'm not sure if maybe I missed something that this is an option but I were not able to find it. Wanted to take the chance and ask if this is the path that we have to go down or do you have any other suggestion how to deal with that?
Thank you very much.
All reactions