Book review: Drupal 8 Development Cookbook

Published October 3, 2016

###Really good content in the wrong format.

Drupal 8 Development Cookbook cover imageDrupal 8 Development Cookbook, written by Matt Glaman is full of useful information about Drupal 8 site building and development - and a worthy addition to anyone's Drupal library. Unfortunately, the "cookbook" format of the book seems to subtract, rather than add, to the usually well-explained concepts throughout.

The book covers an impressive array of topics: Everything from setting up a local environment to many of the technical details of the Entity API. No matter what your skill level with Drupal, there is likely to be something in this book of interest. Having been a Drupal professional for over ten years, I found the chapters on plugins, configuration management, the Entity API and web services especially interesting and educational.

Each chapter (there are 13) includes an often-too-brief introduction, followed by several "recipes." Each recipe includes several sections, including "Getting ready," "How to do it…," "How it works…," "There's more…," and "See also." While the How to do it… sections usually contained the bulk of the narrative, I often found myself wanting more details in the How it works… section. Additionally, I felt that each recipe often didn't have an adequate introduction. The crazy part is that the information I was looking for was often in the How it works… section - presented after the How to do it… section. I think this will lead to some initial confusion by readers asking themselves "why am I doing this?" until they read the How it works… portion. Usually, all of the information was there, just not in the right order (for me at least.) This is especially apparent in the "Plug and Play with Plugins" chapter where I found the How it works… sections more valuable than the How to do it… sections. They really would have been better leading off each recipe.

The author clearly has a firm grasp of the material. This usually shines through in most of the recipes, but there are times in the book where I think the author assumes the reader has a similar level of knowledge - which leads to some disconnects in the narrative. One example of this is the "Creating a custom content type" recipe. There is very little introduction, and I feel that it assumes the reader has a firm grasp of the power of content types (and fieldable entities, for that matter.) This, and several other recipes would benefit greatly from beefed-up introductions (including Features, text formats, some of the Front-end recipes and plugins [especially explaining why we use annotations.])

The recipes also vary widely in their complexity. I'm not sure this if this is a good or bad thing, but perhaps some sort of "complexity level" rating should have been applied to each one to give the reader a heads-up. This is illustrated well with the fact that the plugins chapter assumes the reader has a firm understanding of object-oriented PHP. Granted, I don't expect the author to write a primer on the topic, but a warning in the introduction, or aforementioned complexity level, would have helped smooth the transition into this chapter.

As one example of the format forcing things to be out-of-order, the book begins with the assumption that the reader has a local development stack installed, which is not an unreasonable assumption. But for readers who are new to local development environments, after the recipe to install Drupal 8, in the There's more… section, the author presents valuable information about how to create a database and a database user. There is no mention of this material prior to the How to do it… section. I can easily imagine a scenario where a reader is attempting the recipes in the order they are presented without reading ahead, and being extremely frustrated until they find the There's more… section. A mention of it earlier in the chapter would go a long way here.

The book does a really nice job covering topics I didn't expect to see - including DrupalVM, Entity Reference Views displays, a thorough explanation of a module's .info.yml file and routing files (who knew you could validate a route name with RegEx right in the .routing.yml file!) There is a really nice chapter on configuration management (although more of an introduction on content vs. configuration would have been extremely useful) and Entity API.

For Drupal 7 developers moving to Drupal 8, "The Entity API" chapter is worth the cost of the book. This chapter solidified and extended the knowledge I already had. Its introduction is solid and the chapter includes examples for both content and configuration entities. While it suffers from some of issues I've already mentioned (great content, wrong format,) for the most part it overcomes these challenges and goes much deeper into the topic than I had hoped. Well done!

At the same time, the book also covers a few topics in places where I thought it was a little too aggressive - having a "Running simpletest and PHPUnit" recipe in chapter 1 is a good example. In addition, I believe I spotted a few bugs in the book - both in the narrative and in the code samples - I've forwarded them to the author. Also, in some chapters, the author is writing about a moving target. There are more than a few places where he is forced to reference active Drupal.org issues. As these issues are resolved, recipes may spoil (food pun!)

There were more than a few recipes that involved custom module development; all of which are well-written, technically on-point, and will be extremely useful for Drupal 7 developers moving to Drupal 8. Since this is a book review, I have to pick on one point - all of the recipes were presented as if the developer is writing them from scratch. In reality, I've found the vast majority of Drupal 8 developers building custom modules for clients take full advantage of Drupal Console's "generate" command. While the author does formally introduce this in the last chapter of the book, it feels like it's not in the right place. By introducing it earlier many of the recipes could be written to take advantage of it.

Who would I recommend this book to? If you're a Drupal 7 developer looking to learn Drupal 8 development, this book is a great resource. While there are several introductory and site-building chapters that won't be very useful to you, the more advanced chapters provide (usually) adequate background information along with practical examples (ahem, recipes) to get you going. Would I recommend this book for beginners? If you have a solid PHP background, then yes. In my opinion, the author is more than capable of writing an intermediate-to-advanced Drupal 8 development book - leave the introductory stuff to someone else.

Sign up to receive email notifications of whenever we publish a new blog post or quicktip!

Name
CAPTCHA