Modernizing Legacy Applications in PHP

Get your code under control in a series of small, specific steps
Preview in Mapt
Code Files

Modernizing Legacy Applications in PHP

Paul M. Jones

Get your code under control in a series of small, specific steps

Quick links: > What will you learn?> Table of content

Mapt Subscription
FREE
$29.99/m after trial
eBook
$25.20
RRP $35.99
Save 29%
Print + eBook
$44.99
RRP $44.99
What do I get with a Mapt Pro subscription?
  • Unlimited access to all Packt’s 5,000+ eBooks and Videos
  • Early Access content, Progress Tracking, and Assessments
  • 1 Free eBook or Video to download and keep every month after trial
What do I get with an eBook?
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with Print & eBook?
  • Get a paperback copy of the book delivered to you
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with a Video?
  • Download this Video course in MP4 format
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
$0.00
$25.20
$44.99
$29.99 p/m after trial
RRP $35.99
RRP $44.99
Subscription
eBook
Print + eBook
Start 14 Day Trial

Frequently bought together


Modernizing Legacy Applications in PHP Book Cover
Modernizing Legacy Applications in PHP
$ 35.99
$ 25.20
PHP 7: Real World Application Development Book Cover
PHP 7: Real World Application Development
$ 69.99
$ 49.00
Buy 2 for $35.00
Save $70.98
Add to Cart

Book Details

ISBN 139781787124707
Paperback286 pages

Book Description

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

Chapter 1: Legacy Applications
The typical PHP application
Legacy Frameworks
Review and next steps
Chapter 2: Prerequisites
Revision control
Test suite
Review and next steps
Chapter 3: Implement an Autoloader
PSR-0
A Single Location for Classes
Using The __autoload() Function
Common Questions
Review and next steps
Chapter 4: Consolidate Classes and Functions
Consolidate Class Files
Consolidate functions into class files
Common Questions
Review and next steps
Chapter 5: Replace global With Dependency Injection
Global Dependencies
Common Questions
Review and next steps
Chapter 6: Replace new with Dependency Injection
Embedded instantiation
The replacement process
Change instantiation calls
Review and next steps
Chapter 7: Write Tests
Fighting test resistance
The way of Testivus
Review and next steps
Chapter 8: Extract SQL statements to Gateways
Embedded SQL Statements
Review and next steps
Chapter 9: Extract Domain Logic to Transactions
Embedded Domain Logic
The Extraction Process
Review and next steps
Chapter 10: Extract Presentation Logic to View Files
Embedded presentation logic
Review and next steps
Chapter 11: Extract Action Logic to Controllers
Embedded action logic
Review and next steps
Chapter 12: Replace Includes in Classes
Embedded include Calls
The Replacement process
Review and next steps
Chapter 13: Separate Public and Non-Public Resources
Intermingled resources
The separation process
Common Questions
Review and next steps
Chapter 14: Decouple URL Paths from File Paths
Coupled Paths
Review and next steps
Chapter 15: Remove Repeated Logic in Page Scripts
Repeated logic
Review and next steps
Chapter 16: Add a Dependency Injection Container
What is a Dependency Injection Container?
Review and next steps
Chapter 17: Conclusion
Opportunities for improvement
Conversion to Framework
Review and next steps

What You Will Learn

  • Replace global and new with dependency injection
  • Extract SQL statements to gateways
  • Convert action logic to controllers
  • Remove repeated logic in page scripts
  • Create maintainable PHP code from crufty legacy PHP

Authors

Table of Contents

Chapter 1: Legacy Applications
The typical PHP application
Legacy Frameworks
Review and next steps
Chapter 2: Prerequisites
Revision control
Test suite
Review and next steps
Chapter 3: Implement an Autoloader
PSR-0
A Single Location for Classes
Using The __autoload() Function
Common Questions
Review and next steps
Chapter 4: Consolidate Classes and Functions
Consolidate Class Files
Consolidate functions into class files
Common Questions
Review and next steps
Chapter 5: Replace global With Dependency Injection
Global Dependencies
Common Questions
Review and next steps
Chapter 6: Replace new with Dependency Injection
Embedded instantiation
The replacement process
Change instantiation calls
Review and next steps
Chapter 7: Write Tests
Fighting test resistance
The way of Testivus
Review and next steps
Chapter 8: Extract SQL statements to Gateways
Embedded SQL Statements
Review and next steps
Chapter 9: Extract Domain Logic to Transactions
Embedded Domain Logic
The Extraction Process
Review and next steps
Chapter 10: Extract Presentation Logic to View Files
Embedded presentation logic
Review and next steps
Chapter 11: Extract Action Logic to Controllers
Embedded action logic
Review and next steps
Chapter 12: Replace Includes in Classes
Embedded include Calls
The Replacement process
Review and next steps
Chapter 13: Separate Public and Non-Public Resources
Intermingled resources
The separation process
Common Questions
Review and next steps
Chapter 14: Decouple URL Paths from File Paths
Coupled Paths
Review and next steps
Chapter 15: Remove Repeated Logic in Page Scripts
Repeated logic
Review and next steps
Chapter 16: Add a Dependency Injection Container
What is a Dependency Injection Container?
Review and next steps
Chapter 17: Conclusion
Opportunities for improvement
Conversion to Framework
Review and next steps

Book Details

ISBN 139781787124707
Paperback286 pages
Read More

Read More Reviews

Recommended for You

PHP 7: Real World Application Development Book Cover
PHP 7: Real World Application Development
$ 69.99
$ 49.00
PHP Microservices Book Cover
PHP Microservices
$ 35.99
$ 25.20
Spring MVC: Designing Real-World Web Applications Book Cover
Spring MVC: Designing Real-World Web Applications
$ 69.99
$ 49.00
Learning Docker Book Cover
Learning Docker
$ 39.99
$ 8.00
AJAX and PHP: Building Modern Web Applications 2nd Edition Book Cover
AJAX and PHP: Building Modern Web Applications 2nd Edition
$ 23.99
$ 16.80
Object-Oriented Programming with PHP5 Book Cover
Object-Oriented Programming with PHP5
$ 23.99
$ 16.80