demo
demo copied to clipboard
[Streamlining Entity Design] Introducing the DTOs
I've made some updates to our entity designs to match what the community recommends about Forms -> DTOs -> Entities.
So, the Post entity is now separate from input/request processing, which is handled by the new PostDto. I updated all Post's properties to meet business rules about nullability. For example, since the Post title is required, it’s no longer nullable. This also let me remove the phpstan exceptions about Entity <-> DB mapping mismatches.
I kept things simple on purpose, but we might think about adding required properties in the constructor later (or through semantic constructors) to avoid invalid states.
These changes are only for the Post entity so far. If you like them, let me know, and I can update the rest.
I'll add comments to clarify any changes that might not be immediately obvious.
Cheers!