x
Modernizing Legacy Applications In PHP cover page
Modernizing Legacy Applications In PHP

Suggested

$49.00
Buy Now

Formats Included

Modernizing Legacy Applications In PHP

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

As you apply these incremental refactorings in order, each one building on the last, you will steadily transform your legacy PHP application from a spaghetti mess to an organized, modern, testable application, free of globals and mixed concerns.

Modernizing Legacy Applications In PHP cover page Edit
This book is 100% Complete
Buy Now
$39.00
Minimum
$49.00
Suggested

Free sample

Read Download

Packages

The Book

    • PDF
    • EPUB
    • MOBI

$39.00

Minimum

$49.00

Suggested

Buy Now
The Book, 2 copy license

This is a 2-copy license for the book.

    • PDF
    • EPUB
    • MOBI

$78.00

Minimum

$98.00

Suggested

Buy Now
The Book, 10-copy license

A 10% discount for user groups, schools, large organizations, etc.

    • PDF
    • EPUB
    • MOBI

$349.00

Minimum

$439.00

Suggested

Buy Now

Buy A Bundle And Save

About the Book

"You will breeze through your code like the wind. It will be autoloaded, dependency-injected, unit-tested, layer-separated, and front-controlled."

Is your legacy PHP application composed of page scripts placed directly in the document root of the web server? 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? If so, you already know that the wide use of global variables means that making a change in one place leads to unexpected consequences somewhere else. These and other factors make it overly difficult and expensive for you to add features and fix bugs. Working with this legacy application feels like dragging your feet through mud.

But it doesn't have to be that way! This book will show you how to modernize your application 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. Moreover, we will 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.

Please note that this book is about modernizing in terms of practice and technique, and not in terms of tools. We are not going to discuss the latest, hottest frameworks or libraries. With the exception of testing systems like PHPUnit, and one or two standalone third-party libraries, the book does not advocate adding third-party code to your existing legacy application. Most of the very limited code we do 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.

If you feel overwhelmed by a legacy application, "Modernizing Legacy Applications in PHP" is the book for you. If you prefer a paper copy, you can purchase one at Lulu.com.

If you're still on the fence, the video "It Was Like That When I Got Here" (embedded above on this page) outlines the first few chapters for free, and you can read some reviews of the book on the feedback page. You can also read the 4.5-star review from SitePoint.

Be sure to follow the book on Twitter @mlaphp, and tell all your friends!

  • Feedback
  • Share this book

Table of Contents

  • Foreword
  • Preface and Acknowledgments
  • 1 Legacy Applications
    • The Typical PHP Application
    • Rewrite or Refactor?
    • Legacy Frameworks
    • Review and Next Steps
  • 2 Prerequisites
    • Revision Control
    • PHP Version
    • Editor/IDE
    • Style Guide
    • Test Suite
    • Review and Next Steps
  • 3 Implement An Autoloader
    • PSR-0
    • A Single Location For Classes
    • Add Autoloader Code
    • Common Questions
    • Review and Next Steps
  • 4 Consolidate Classes and Functions
    • Consolidate Class Files
    • Consolidate Functions Into Class Files
    • Common Questions
    • Review and Next Steps
  • 5 Replace global With Dependency Injection
    • Global Dependencies
    • The Replacement Process
    • Common Questions
    • Review and Next Steps
  • 6 Replace new With Dependency Injection
    • Embedded Instantiation
    • The Replacement Process
    • Common Questions
    • Review and Next Steps
  • 7 Write Tests
    • Fighting Test Resistance
    • Setting Up A Test Suite
    • Common Questions
    • Review and Next Steps
  • 8 Extract SQL Statements To Gateways
    • Embedded SQL Statements
    • The Extraction Process
    • Common Questions
    • Review and Next Steps
  • 9 Extract Domain Logic To Transactions
    • Embedded Domain Logic
    • Domain Logic Patterns
    • The Extraction Process
    • Common Questions
    • Review and Next Steps
  • 10 Extract Presentation Logic To View Files
    • Embedded Presentation Logic
    • The Extraction Process
    • Common Questions
    • Review and Next Steps
  • 11 Extract Action Logic To Controllers
    • Embedded Action Logic
    • The Extraction Process
    • Common Questions
    • Review and Next Steps
  • 12 Replace Includes In Classes
    • Embedded include Calls
    • The Replacement Process
    • Common Questions
    • Review and Next Steps
  • 13 Separate Public And Non-Public Resources
    • Intermingled Resources
    • The Separation Process
    • Common Questions
    • Review and Next Steps
  • 14 Decouple URL Paths From File Paths
    • Coupled Paths
    • The Decoupling Process
    • Common Questions
    • Review and Next Steps
  • 15 Remove Repeated Logic In Page Scripts
    • Repeated Logic
    • The Removal Provess
    • Common Questions
    • Review and Next Steps
  • 16 Add A Dependency Injection Container
    • What Is A Dependency Injection Container?
    • Adding A DI Container
    • Common Questions
    • Review and Next Steps
  • 17 Conclusion
    • Opportunities for Improvement
    • Conversion to Framework
    • Review and Next Steps
  • Appendix A: Typical Legacy Page Script
  • Appendix B: Code Before Gateways
  • Appendix C: Code After Gateways
  • Appendix D: Code After Transaction Scripts
  • Appendix E: Code Before Collecting Presentation Logic
  • Appendix F: Code After Collecting Presentation Logic
  • Appendix G: Code After Response View File
  • Appendix H: Code After Controller Rearrangement
  • Appendix I: Code After Controller Extraction
  • Appendix J: Code After Controller Dependency Injection
  • About the Author

About the Author

Paul M. Jones is an internationally recognized PHP expert who has worked as everything from junior developer to VP of Engineering in all kinds of organizations (corporate, military, non-profit, educational, medical, and others). Paul's latest open-source project is Aura for PHP. Among his other accomplishments, Paul is the lead developer of the Solar Framework, and the creator of the Savant template system. He has authored a series of authoritative benchmarks on dynamic framework performance, and was a founding contributor to the Zend Framework (the DB, DB_Table, and View components). Paul is a voting member of the PHP Framework Interoperability Group, where he shepherded the PSR-1 and PSR-2 recommendations, and was the primary author on the PSR-4 autoloader recommendation. He was also a member of the Zend PHP 5.3 Certification education advisory board. He blogs at paul-m-jones.com. In a previous career, Paul was an operations intelligence specialist for the US Air Force, and enjoys putting .308 holes in targets at 400 yards.

Other books by this author

The Leanpub Unconditional, No Risk, 100% Happiness Guarantee

Within 45 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks. We process the refunds manually, so they may take a few days to show up.
See full terms.