Modernizing Legacy Applications in PHP: Review
Chances are you’ve come across some horrible legacy code once or twice in your lifetime as a PHP developer. Heck, if you’ve worked with WordPress to any degree, I’m sure you have. I myself have had the satisfying task of modernizing a monolithic ZF1 application, and it was the most mentally exhaustive (but, admittedly, the most educational) year of my career.
If only I had had Paul M. Jones’ “Modernizing Legacy Applications In PHP” book back then, I would have been done in half the time, and the work I did would have been twice as good.
Many thanks to Paul for providing me with a review copy after having read my review of Design Patterns in PHP. The book is a Leanpub publication – meaning it’s self-published – but that’s where similarities with other Leanpub content I’ve consumed so far end.
Modernizing Legacy Applications in PHP is a detailed step by step guide in turning a spaghetti mess of old PHP code you’ve probably inherited from a team that left two generations ago, into a sort of fully fledged MVC application with the front controller, router, dependency injection, and even unit tests.
Rather than regurgitating common examples found online and various Wikipedia definitions in shortened form, the book takes a hands on approach with sample code eerily similar to things I’ve seen over and over again in legacy projects. This not only verifies a senior developer’s suspicions about the similar state of decrepitude in most legacy apps, but also inspires one to delve deeper as it seems most of us share the same problems at some time and, thus, can use the same solutions.
This book is not for beginners. I mean, if you’re a beginner, I recommend getting it right away and just keeping it in your Leanpub dashboard for when you’ll be able to implicitly recognize the terms discussed within; but if you don’t have a horrible large-scale legacy project or two under your belt before you start reading it, you won’t understand much and ploughing through the content on auto-pilot without knowing what it does is counterproductive at best. Besides, you’ll probably do it wrong because every legacy app is different, despite most of them being similar.
This book is aimed at intermediate and higher level PHP users, with an emphasis on seniors. Intermediate devs won’t get 100% out of it. They’ll understand more of the content, and they’ll be able to use some of it as a prevention against future horrors while working on their apps right now (which, again, is reason enough to recommend a purchase), but intermediate devs are generally still getting familiar with best practices and haven’t been out of the procedural marshes for very long, the mud and sludge still dripping from their “I finally know PHP” shirts.
The book, however, really shines as a guidebook for professional and higher devs. As someone intimately familiar with all the aspects discussed within, I could approach each chapter as a challenge. Every chapter is named after what we’ll be doing in it – a single phrase summary – which allowed me to imagine the approach I would take in doing it, and then compare it with the solution presented within. Every chapter makes use of modern practices and terms only people with decent amounts of PHP experience are intimately familiar with (unfortunately – let’s work on that!) like IoC, DI, custom FrontController, Routing, URL Rewrites and the still too neglected Unit Testing, and only a seasoned developer will be able to implicitly understand why an approach is needed in a given scenario without questioning the “why”, instead focusing immediately on “how best to”.
On a technical level, the book is sound – amazingly so. Each chapter follows a specific step in the modernization process and presents “before” and “after” code. What’s more, the code looks real – it’s not just another “Acme” controller, just another Foo/Bar you’ve seen everywhere.
This looks like it was taken out of a real project which makes it instantly relatable to developers who find themselves in the problems this book solves.
The book is also accompanied by online materials in form of open source classes that get plugged into the modernization process at one time or another and help with bootstrapping some solutions.
Apart from what I’ve already listed in previous paragraphs, the author paid much attention to detail, at various places including relevant links to terminology and concepts that might be unfamiliar to the reader. The book is well written, with sentences concise and clear and is a fluent read (except in some cases – see below).
The typos were minimal, and it’s here that I must stress the importance of editing. Leanpub authors, you are not your own worst critic and you are not fit to be your own editor. On that note, neither are your friends, relatives, and so on. If you’re writing a book, you need someone who is either objective or professional enough (preferably both) to give you good, proper feedback (positive or negative), and one who can follow your progress from chapter to chapter. Finding out the book sucks when you’ve already written it helps no one – you can’t rewrite it easily, you can’t change its flow, and generally, you wasted a good opportunity.
Paul’s book has been well edited by various parties on various aspects, and it shows. Next to no errors, perfect formatting, best practices, good explanations and excellent examples are what set this book above the typical Leanpub product. Additionally, despite being the lead on the AuraPHP project, Paul made absolutely no effort to get the reader to convert to it, or to use its components in the modernization process. This, along with the other upsides, shows that the book is meant to be a long term quality resource rather than self-promotion.
The only downside I could find was that some chapters referenced appendices with code instead of discussing and improving the code inline, which sometimes broke the reading fluency, causing awkward back-and-forth jumps between content – something e-readers and PDF readers have yet to nail down perfectly. If I were to improve anything in a second release, it would be to make sure all chapters follow the approach of the first and last few – embedded code, and no Appendix jumps (though Appendices should still be kept as is, for future reference). This would lengthen the book somewhat, but would allow for a smoother reading experience.
In conclusion – go buy this book now.
Really, on a scale of 5 elephpants I can easily give it a 4.5 (the half an elephpant off just for the “con” I listed above). It’s the perfect guidebook to legacy modernization and I can see myself coming back to it in the future as I meet the coming horrors of old apps.
The book is available on Leanpub, and Paul was kind enough to offer a 10% discount coupon for SitePoint readers. To use it, just hit this link.