Doctrine is one of the most famous open source ORMs for PHP. It’s based on data mapper architecture, so the core is all separated from entities. There is an Entity Manager that is in charge of doing CRUD .
Suppose that we’ve got an entity for books:
And another for chapters:
And there is a html form for adding a new book with this input for title:
<input type="text" name="title" />
So we receive form data as an array in BookController and new Book is supposed to be added like this:
Everything is neat and simple till we’ve got a few fields on book, but what if there are dozens of field? then we got to call all of the setter methods statically, also controllers are not supposed to do the logic, they receive data and pass it to other layers to do the rest of work. …