PHP 7 Explained: A review

Submitted by Larry on 31 December 2016 - 1:50pm

The team over at thePHP.cc recently published an ebook entitled PHP 7 Explained, "Everything you need to know about the next generation."

A few weeks back, I received an email from them stating "As a token of our appreciation for your involvement in the PHP community we would like to gift you a copy of our eBook." Yay, free stuff! Since I'd gotten it free, and it's of timely use to the PHP world, I decided to publish a formal review.

Disclaimer: I was not asked to write a review, although the authors did ask for feedback. The only compensation I receive for this review is the book itself, which was sent without the expectation of a review. Also to the authors, yes feel free to quote portions of this review on the books site as long as it's credited.

PHP 7 Explained is, in short, the most detailed changelog you'll ever read. That is both a complement and a criticism depending on your point of view. In the context of what it's trying to do I intend it more as a complement.

The book offers an exhausive (I presume, as I've not read through every language RFC in detail myself) overview of the changes to PHP in versions 7.0 and 7.1 and their implications. High-profile changes like the improved typing system or anonymous classes are show side by side with edge cases that I didn't even know existed (but now want to find a use for as they seem cool), yet are still changes in the language. It also covers some of the history of PHP 7 and the underlying engine changes that are responsible for PHP 7 being so much faster than previous versions.

As far as detail, the book nails it. As a fluent PHP developer I found the book overall well-targeted and easy to follow. Examples were simple and unconfusing and most descriptions were straightforward and readable. PHP 7.0 and 7.1 are also condensed into a single flow, rather than a dedicated "7.1 chapter", which is also appreciated.

Most books on a programming language by tradition include a section on Installation and PHP 7 Explained is no different. What it does right here, which few books do, is keep the instructions to a page and a half total by simply pointing readers at the appropriate existing repository for their OS (Red Hat, Debian, Ubuntu, Mac, and Windows, many with multiple versions). There's zero discussion of compiling PHP yourself (nor should there be in such a book). It's just a list of recommended repositories. More books should take this approach.

I did notice a few bugs in the text. Most were spelling or typographical issues that imply a lack of copyediting, and could be easily fixed in later updates. The one major issue I found, though, was a doosey. When discussing return types, the book states:

Return type declarations are independent of the declare(strict_types=1); setting that we discussed in the previous section on scalar type declarations and are always enforced.

Except that's not true. Return types follow the same coercion-or-strict toggle as parameters, but are enforced on the return. Compare weak mode vs strict mode yourself. That's a rather serious gaff for what is otherwise a very robust book. (Hopefully that line can also be corrected in future versions. Also, hopefully those links will remain working for a while...)

My other major concern with the book is its organization. While the content itself is overall quite good, I couldn't quite figure out why sections were in the order they were in. Looking at the book's table of contents, the overall order is (rephrased by me to make the point):

  • Introduction
  • Some Backward-Compatibility (BC) breaks
  • Engine improvements
  • Installation
  • BC breaks in things that were bad to begin with
  • New features (types)
  • New features
  • Other new features
  • Still more new features
  • Error-handing-related new features
  • Windows
  • Yet more BC breaks
  • Stuff that got removed, which is different than a BC break?

That makes four separate chapters of things that changed in BC-breaking ways, and five separate chapters on new stuff. The regular flip-flopping between the two is confusing and makes it hard to follow the progress of the book.

Despite its warts, I would still say PHP 7 Explained fulfils its primary function: It provides a straightforward, approachable, exhausive list of everything a fluent PHP 5 developer needs to know both to use PHP 7 and to know why to use PHP 7. It is, quite literally, explaining everything about PHP 7 that developers making the transition need to know. It's probably not useful for anyone just coming to PHP, but even for developers who follow PHP-Internals development (like yours truely) there is plenty of new and worthwhile material. For PHP developers still wondering what all the fuss is about, it's a very good investment.

Verdict: This review is an endorsement.