Chapter 16. Add a Dependency Injection Container

We have reached the final step in our modernization process. We will remove the last vestiges of our page scripts by moving their remaining logic into a dependency injection container. The container will be responsible for coordinating all the object creation activity in our application. In doing so, we will modify our front controller again, and begin adding routes that point to controller classes instead of file paths.

Note

For this final step in the modernization process, it is best if we have PHP 5.3 or later installed. This is because we need closures for critical parts of the application logic. If we do not have access to PHP 5.3, there is a less viable but still workable option for implementing ...

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.