Image for post
Image for post

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. …



Busy killing zombies

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store