Have you taken advantage yet of SitePoint’s limited-time launch special for the newest PHP book, PHP Master: Write Cutting-Edge Code by Lorna Mitchell, Davey Shafik, and Matthew Turland? If not, you’re crazy! The book was written explicitly to help you becoming a better PHP programmer and is totally awesome. It not only covers advanced PHP coding topics such as object-oriented programming and design patterns, but also periphery topics that are just as important, such as security, performance profiling, and deployment. If you’re ready to hang up your novice hat for good and become a professional-level PHP developer, this book is for you.
I was pleasantly surprised from the moment I started flipping through its pages (virtually speaking of course as I have the PDF version); the blend of topics discussed is well balanced and the writing styles of authors makes sometimes difficult concepts clear and understandable. The authors are real-world PHP developers themselves, so they approach the topics with pragmatism and offer you sound, practical advice without the hype found in today’s industry.
PHP Master begins by laying a foundation of object-oriented programing in Chapter 1 and then covers interfacing with relational databases like MySQL through PDO in Chapter 2 and several useful design patterns in Chapter 4. Chapter 3 is a great introduction to working with and adding APIs that transfer information using RPC, SOAP, and REST.
The second-half of the book covers security and quality assurance topics. Chapter 5 is devoted entirely to security and explains how to protect yourself from cross-site scripting attacks, session fixation and hijacking, SQL-injection attacks, and more. Performance measuring using the Apache benchmarking tool
ab and JMeter, as well as guidance on implementing a caching strategy, is covered in Chapter 6. Chapter 7 introduces automated testing concepts to ensure your codebase functions correctly throughout development, and Chapter 8 discusses metrics used to improve the quality and maintainability of your code.
The three appendices in the back of the book can be thought of as cool bonus chapters. Many books just toss in extra trivial information in an appendix, but the appendices in PHP Master provide thorough information on PEAR and PECL (from installing packages to creating your own packages and channels), the Standard PHP Library (covering registering multiple autoloaders, directory iterators, and data structures), and advice on how to continue growing as a PHP developer.
There are some minor oddities in the book, but by no means are they a deal breaker. For example, a chart in Chapter 6 labeled “Performance Figures with and without Memcached” shows the performance effect of storing session data within the file system, MySQL, and Memcached, though a MySQL-based scenario is never covered; perhaps it got trimmed during editing and not all of the references were removed. Another one is that
ab is covered twice, once in Chapter 6 and again in Chapter 7, an oversight that’s easy enough to make when a book has multiple authors. I would have expected it to be caught by an editor or proofreader before the book went to press, though. The otherwise awesome content overshadows the few oopses I found.
I appreciate the sober approach taken with the topics at hand; the authors’ pragmatism is refreshing in Chapter 4, for example. I’ve watched the popularity of design patterns rise to fanboi heights and yet it was explained why the patterns were useful but stressed the importance of using the right tool (or design pattern in this case) for the right job, as this quote illustrates:
You may see this pattern in a number of settings, and now you can also build it into your own applications, if appropriate.
Presenting good practices and encouraging responsible use of them is definitely best practice!
I also enjoyed the discussion and examples concerning web services in Chapter 3, perhaps because its applicable to a project I’m working on currently. Practical advice is woven throughout the chapter, for example this quote talking about publishing a REST service:
Whenever you publish a RESTful service, it’s likely that someone, somewhere will complain that you have violated one or more principles of REST—and they’re probably right! REST is quite an academic set of principles which doesn’t always lend itself well to business applications. To avoid criticism, simply market your service as an HTTP web service instead.
Readers are reminded it’s not the buzzwords and dogmatic arguments that are important, but what they do with the technologies they describe to create exciting applications.
Using the Slashdot scale of book ratings, where 1 is fit for lining cages and 10 is destined to be a classic, I give PHP Master: Write Cutting-Edge Code a very solid 8.5. The content will grow with you and the book is not something you’ll read in a weekend and then donate to the library because you have no need for it. The advanced coding and periphery topics covered in the book will help you to ratchet up your skill level and become an awesome coder. You’ll also be sure you’re getting an excellent, well-grounded education in the process. If you’re serious about becoming a better PHP developer then you need this book on your bookshelf or e-reader!