Drupal 8 Development Tools

Drupal Console

The Drupal Console is a tool to help generate boilerplate code and files that are used in Drupal 8 module development. It is a Command Line Interface (CLI) for Drupal similar to Drush but based on the Symfony Console component. Like Drush, you can rebuild caches and install modules but unlike Drush it allows you to generate most of the code needed for a Drupal 8 module, saving a lot of time. Find out more about Drupal Console.


Kint

Kint is a tool designed to present your debugging data in the absolutely best way possible. Now Drupal heavily uses OOP, Kint is needed to replace the old dpm() dsm() functions that use Krumo to display data. The old debugging functions in Devel like dsm() are still there, but they no longer use Krumo so the data is printed without any formatting. Kint comes as a sub-module within Devel and once installed you simply need to call kint() or ksm(). Kint can also be used in Twig templates, although you need Twig debugging turned on first.

Kint is great, but I find it very slow when clicking the + icon if there is a lot of data. This is because it expands everything to show you all data. Instead, just click an item instead and it only expands to show you inside that item. Also, there's a little arrow on the right, if you click that it opens up a new tab in your browser and shows the data there.

kint.gif


Search Kint

The great thing about the Devel functions that use Krumo in Drupal 7 is that you could click on the item to get the path. Currently, Kint does not do that. There is however a module called Search Kint that allows you to quickly get the full path. It also provides a field so you can search the dump.

kint-search.gif


PhpStorm

I believe most of the big brains in Drupal use PhpStorm - apparently Acquia developers use it. I have always used Netbeans when developing in Drupal 7 (previously using Eclipse and Aptana), so I thought it would be a good time to switch to PhpStorm when learning Drupal 8.

Update: After getting used to PhpStorm and putting all my projects on there, I can honestly say this is by far the best IDE I've used. I think specifically for Drupal 8 development, there really isn't any other option because of the Drupal/Symfony support it offers. Well worth paying for. RIP Netbeans.


ChromePHP/Chrome Logger for AJAX debugging

In Drupal 7 I used FirePHP to debug Drupal AJAX forms. As I'm now learning to develop AJAX forms using Drupal 8 I thought I'd try something different. I'm using ChromePHP with the Chrome Logger extension to see variable dumps in the Chrome developer tools console. To use it, install the Chrome extension by going here:

https://chrome.google.com/webstore/detail/chrome-logger/noaneddfkdjfnfdakjjmocngnfkfehhd?hl=en

Then go to your Drupal project folder on the command line and do the following command:

composer require ccampbell/chromephp

The go to your site root (if it's not the same place as your project directory - I use /web) and clear the cache:

drush cr

 Then go to the Devel Settings page and change the 'variable dumper' to ChromePhp.

chromephp.png

Now when you use the functions dsm() or dpm() the data is shown in the Chrome console.

chrome-console-dsm.png


Drupal Coder

Coder is a library for automated Drupal code reviews and coding standard fixes. It defines rules for PHP_CodeSniffer

Built-in support for:

It works well with the PhpStorm IDE.