Submitted by Steve Purkiss on Fri, 07/10/2016 - 10:39
Drupal Console logo

I am a big fan of Drupal Console, the CLI built on top of Symfony Console for use with Drupal 8. As well as the ability to generate skeleton code, Drupal Console has a heap of commands for a number of uses, routing, debugging, and now with the new field:info command you can gain an overview of what fields are on a site and where they are used.

A bit of background

I wrote this last month as a result of attending the Drupal Global Sprint Weekend - London Outpost which was focusing on Drupal Console. I'd been wanting to learn how Drupal Console worked for a long time, and as it's always easier when sitting around a table with other Drupalers I jumped at the opportunity and made my way up to the Big Smoke for the day. Big thanks due here to Robert Castelo for organising the sprint, and for keeping the Drupal lights on in London for all these years - I believe it was one of, if not the first, local Drupal User Group!

I managed to get all the info I needed to set up my machine on the Saturday in order to contribute to the project and take on an issue from the Drupal Console GitHub issue queue - one was a feature request for this command which looked like something I could achieve, so decided upon that as my task. It ended up taking a couple of weeks to write and I'm extremely happy with the results, of course I learned much on the way too so I never see it as 'contribution' but more as 'free learning' for me! A big thanks here to the DrupalConsole team who provided me with a lot of help over on the Drupal Console chat channel.

Stealing code is a Good Thing

I discovered a Drupal module which had the basic functionality I needed for this command - Field Report - which I then re-factored for use in Drupal Console and added the extras for the options. I even managed to contribute a patch back to the Field Report module to fix an issue they had, which was nice to be able to do as I'd used their code!

A quick retropective

I think the hardest part was getting the display to look nice, however as my first 'professional' programming was RPG (Report Program Generator, not Role Playing Games unfortunately!) for IBM AS/400s which originated from punch cards I was used to figuring out text-only outputs ;) Apart from that is was just a case of reading the Symfony Console documentation to understand how options and arguments work, and which one to use for particular purposes.

The field:info Screencast

And finally at last, here's the field:info screencast ~ enjoy!



Submitted by rphair (not verified) on Fri, 14/10/2016 - 16:40


Thanks to you, I saw this live at DrupalCon Dublin... which became my motivation to finally get Drupal Console working. In case anyone wonders why they don't see it on a stock install, I had to do "composer require drupal/console:1.0.0-rc5" which for me required a more recent version of symfony/dom-crawler ("composer require symfony/dom-crawler:2.8.12").

I had always hoped something like this would be available in Drupal & thanks for sharing. It's also a great preview for the things you can do in Drupal Console that are really hard to do any other way.

Thanks Robert, I enjoyed that little Tour de Drupal in the pub! Glad you got into console, it's pretty awesome & thanks for sharing the tip - as I showed you in my composer.json I just put "~8.0" for any Drupal module so when I do a composer update it'll grab the latest version - for console I guess something like "~1.0" will also do similar... YMMV etc.

Happy Drupaling!

Add new comment

By submitting this form, you accept the Mollom privacy policy.