Skip to content

Conversation

@Crell
Copy link
Owner

@Crell Crell commented Nov 27, 2022

This is a WIP at the moment. The goal is to get to the point where we can write a class analyzer (from AttributeUtils) that, instead of parsing with reflection, will read from a YAML file that has been hand-crafted. But we also want the ability to write out a template of said file from the class/attributes.

The goal is to allow things like defining the ORM settings or serializer settings entirely in YAML, without having to put attributes into the class. (Also doing JSON or array would be trivial at that point, but YAML is the most popular target.)

I'm now reasonably confident that this will work, but not on the particular way I have it working. I'm putting this PR up in case anyone else wants to weigh in before I next find time to play with it.

Feedback welcome at this point.

@robiningelbrecht
Copy link

robiningelbrecht commented Sep 5, 2025

Hi @Crell , are you planning on ever implementing this feature? Seems very promising.
I got this fully working by adding one attribute to the $typeField property in the Field class:

    #[ClassNameTypeMap(key: 'type')]
    public readonly ?TypeField $typeField;

This allows Serde to use the correct TypeField when deserializing

@Crell
Copy link
Owner Author

Crell commented Sep 5, 2025

Yeah, I still want to do this. It's just never been a high enough priority for me to get to. (And I have a kid now. 😄 )

If you want to send a new PR or a PR against this one, I can try to have a look at some point. Though it likely needs a rebase, too... As I said, I'm not sure the code here is the right way to do it, but it confirms that it can be done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants