-
Book Overview & Buying
-
Table Of Contents
Modernizing Legacy Applications in PHP
By :
Modernizing Legacy Applications in PHP
By:
Overview of this book
Have you noticed that your legacy PHP application is composed of page scripts placed directly in the document root of the web server? Or, do your page scripts, along with any other classes and functions, combine the concerns of model, view, and controller into the same scope? Is the majority of the logical flow incorporated as include files and global functions rather than class methods? Working with such a legacy application feels like dragging your feet through mud, doesn’t it?This book will show you how to modernize your application in terms of practice and technique, rather than in terms of using tools such as frameworks and libraries, by extracting and replacing its legacy artifacts. We will use a step-by-step approach, moving slowly and methodically, to improve your application from the ground up. We’ll show you how dependency injection can replace both the new and global dependencies. We’ll also show you how to change the presentation logic to view files and the action logic to a controller. Moreover, we’ll keep your application running the whole time. Each completed step in the process will keep your codebase fully operational with higher quality. When we are done, you will be able to breeze through your code like the wind. Your code will be autoloaded, dependency-injected, unit-tested, layer-separated, and front-controlled. Most of the very limited code we will add to your application is specific to this book. We will be improving ourselves as programmers, as well as improving the quality of our legacy application.
Table of Contents (29 chapters)
Preface
1. Legacy Applications
2. Prerequisites
3. Implement an Autoloader
4. Consolidate Classes and Functions
5. Replace global With Dependency Injection
6. Replace new with Dependency Injection
8. Extract SQL statements to Gateways
9. Extract Domain Logic to Transactions
10. Extract Presentation Logic to View Files
11. Extract Action Logic to Controllers
12. Replace Includes in Classes
13. Separate Public and Non-Public Resources
14. Decouple URL Paths from File Paths
15. Remove Repeated Logic in Page Scripts
16. Add a Dependency Injection Container
17. Conclusion
A. Typical Legacy Page Script
B. Code before Gateways
C. Code after Gateways
D. Code after Transaction Scripts
E. Code before Collecting Presentation Logic
F. Code after Collecting Presentation Logic
G. Code after Response View File
H. Code after Controller Rearrangement
I. Code after Controller Extraction
J. Code after Controller Dependency Injection
Index