Author: Josh Lockhart
Audience: Developers with experience of PHP
Reviewer: Alex Armstrong
PHP, a modern language? Yes it is now but how do you convert from using it as a simple scripting language to something more modern?
This book is for PHP programmer wanting to discover all of the more advances in the recent releases and the PHP offshoots like Facebook's HVVM and Hack languages. It is divided into three sections - Language features; Good practices; and Deployment testing and tuning.
The first section on the new language features is probably what you bought the book for but it occupies only just over 30 pages. The big problem is that the topic don't really have any obvious logical organization. After a quick introduction to PHP's history, the book gets started proper at chapter 2. The topics covered by Josh Lockhart are - namespaces, interfaces, traits, generators, closures, OPcache and the built in HTTP server. You can see that there isn't much communality between the topics. The final section on OPcache and the HTTP server aren't even about language features. If you have encountered any of the ideas before in other languages then you might find the explainations a bit too slow. These are aimed at the PHP programmer who hasn't seen much of the outside world.
The next part of the book is more a general collection of ideas of how you should use and organize PHP. Chapter 3 is about standards - mostly PSR - PHP Standards Recommendations. Chapter 4 is about components as alternatives to frameworks. Chapter 5 is called "Good Practices" and it is a long list of things you should and shouldn't do - sanitise input, working with passwords, database, multibyte strings and so on.
This part of the book isn't really about new features that have come about to make PHP better, but things you could have done in PHP at earlier times. Still, if you are going to write modern PHP you need to make the best attempt you can.
The third and final part of the book is about deployment, testing and tuning. It starts with a chapter on the choices you have for hosting - with very little description of using cloud based services. It then deals with provisioning - basically getting started. This really doesn't have enough information to help the beginner and doesn't go far enough for the expert. The whole section on deployment isn't deep enough.
Next we move on to tuning. This is matter of configuring PHP and using OPcache and is very short. Then back to deployment - one of the most difficult topics when it comes to PHP web sites, but it only deals with Capistrano and not the wider issues of development versus production.
Chapter 11 is a short chapter on profilers including xdebug - again to short to be useful. Chapter 12 is about HHVM and Hack and is no more than an awareness raiser. The book concludes with a chapter about the PHP community, which compared to that of to many other languages, Python and Ruby in particular, is fairly weak.
Overall this is a good read if you are wanting to know a little more about "modern PHP", but it misses a lot out and fails to discuss the new features in sufficient length and depth. Each one could have been expanded to a complete chapter with examples of their use. If the new language features are what you are interested in then you will probably think that it is "padded" with a lot of standard material such as testing, profiling and so on. Of course if you don't know about these topics then the book makes a good introduction, but no more than an introduction. Missing from the book is any mention of using a modern IDE and debugger and no discussion of using a remote server to do development. PHP is still a difficult language to work with if you are developing a large system and solving this is very much part of modern PHP.