With the popularisation of DDD people started shifting from anemic models with only getters and setters to a rich model describing the state changes in specific methods. This way of designing models does not play well with Symfony forms. User provided input is inherently invalid while we want to maintain certain invariants in our domain model. A common approach to overcome these limitations is to create data transfer objects our forms are then bound to. This can lead to lots of mapping & glue code that might be cumbersome to write and maintain. But couldn’t we do better? In this talk we will discuss the different aspects of a rich domain model that makes it hard to use it in conjunction with the Form component. We will then look at the possibilities to hook into the data flow of the form handling and discover how we can modify it to interact seamlessly with our model.


Comments are closed.

Very interesting talk and hopefully will be a must-have bundle or eve part of the core

Good but not great. That's understandable since it was the first public show. I suggest to add a summary and a conclusions slide. Also I suggest to keep same codebase with subsequent commits instead of jumping back and forth between different solutions.

Interesting topic. I know it was hard as the first time. Small tip for the next time - add small bookmark/avatar/icon on each slide - one colour for one speaker. You will exactly know who should speak when :)

More of a concept talk. Lots of misunderstanding in what DTO, Data Mapper are (yes, these are not alternatives – one to another – you actually use Data Mapper to convert Entity to DTO / Domain Model). In the end, promised removal of Glue Code happened to be … another glue code (with Data Mapper, see the repository!) structured as a bundle.

I'd rather see how to properly distinguish Entity objects from DTOs, why DTOs are safer (immutability, for instance), and how to use with Forms, than giving a talk to put some background for own proposal (RichModelFormsBundle).

Christopher Hertel (Speaker) at 14:30 on 30 Sep 2018

Hi Marcin,

thank you for your feedback! You are right, we could - as another way - combine data mappers and dtos and we missed to mention that. but using them without each other is a valid solution to the problem and the pro and cons are still valid.
we should also be more explicit about what glue code means to us, because using this bundle and not writing DTOs and DataMappers for yourself is getting rid of glue code between your domain and the bundle in your application.
and you are also right that we are using data mappers in the bundle implementation as well - so does the symfony core and i don't think there's another sensible way.
the purpose of the bundle is to test and discuss ideas about using symfony forms with rich domain models and bring proven ones to the core.

Thanks again for your feedback, we will try to be more clear about our ideas at the next conference!

I'd be glad to bring this discussion to slack, so just ping me if you like to!



Patrick Vale at 10:45 on 1 Oct 2018

Interesting and well-presented. Hits the button on an area I've been working with (rich domains with forms and DTOs) at the moment. The returning slide with the components listed, showing which had been added/removed in each solution was very good.

Gavin Chapman at 14:47 on 5 Oct 2018

Good talk, but the code on the slides was unreadable due to the dark colour and it being projected, and having colour blindness it was made worse as I couldn't see the laser pointer either.