Chapter 11. Extract Action Logic to Controllers

Thus far, we have extracted our model domain logic and our view presentation logic. Only two kinds of logic remain in our page scripts:

  • Dependency logic, which uses the application settings to create objects
  • Action logic (sometimes called business logic) which uses those objects to perform the page actions

In this chapter, we will extract a layer of Controller classes from our page scripts. These will handle the remaining action logic in our legacy application separately from our dependency-creation logic.

Embedded action logic

For an example of embedded action logic mixed with dependency logic, we can look at the ending example code from the last chapter in Appendix G, Code after Response View File

Get Modernizing Legacy Applications in PHP now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.