Chapter 15. Remove Repeated Logic in Page Scripts
As things are now, the logic in our page scripts is highly repetitive. They all look very similar. Each one loads a setup script, instantiates a series of dependencies for a page controller, invokes that controller, and sends the response.
Our front controller gives us a place where we can execute the common elements of each page script and remove that repetition. Once the repetition has been removed, we can begin to eliminate the page scripts themselves.
Repeated logic
In essence, each of our page scripts follows this organizational flow:
Generic Page Script 1 <?php 2 // one or more identical setup scripts 3 require 'setup.php'; 4 5 // a series of dependencies to build a controller 6 $request = new ...
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.