Chapter 12. Replace Includes in Classes

Even though we have Model View Controller separation now, we may still have many include calls in our classes. We want our legacy application to be free from the artifacts of its include-oriented heritage, where merely including a file causes logic to be executed. To do so, we will need to replace include calls with method calls throughout our classes.

Note

For the purposes of this chapter, we will use the term include to cover not just include but also require, include_once, and require_once.

Embedded include Calls

Let's say we extracted some action logic with an embedded include to a Controller method. The code receives information on a new user, calls an include to perform some common validation functionality, ...

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.