Podcast No. 58: Drupal Console

Image
It's the Drupalize.Me podcast!

This week on the podcast, I chatted with Jesus Manuel Olivas about the Drupal Console project.

Listen here: Podcast Episode 58: Drupal Console

What is the Drupal Console?

The Drupal Console is, at this time, a suite of tools that you run on a command line interface (CLI) to generate boilerplate code and interact with a Drupal 8 installation.

Similar tools include:

  • Module Builder: (Generates Drupal 6, 7, or 8 module scaffolding)
  • Drupal Module Upgrader: (Converts modules from Drupal 7 to Drupal 8; generates static help file with links to relevant change records)
  • Drupal 8 Tools: (Drupal code generator written in bash)
  • Drush (Interact with Drupal installation via CLI, create aliases, create custom commands)

What makes Drupal Console unique?

From the ground up Drupal Console is using the modern PHP practices introduced into Drupal 8, including object-oriented PHP. The Drupal Console isn't a Drupal module, but was built with the Symfony Console Component and other libraries, such as Twig, to generate PHP, YAML, and other file types used in Drupal 8 module development. It is a tool designed for anyone using or planning to use Drupal 8. At the moment, it is used via a CLI, but there are plans to make it accessible through the Drupal administrative interface. Drupal Console works with Drupal 8, and because of the nature of its code base and use of modern PHP, will not be ported to work with Drupal 6 or 7, but instead plans to support Drupal versions from 8 onward.

How does Drupal Console differ from Drupal Module Upgrader?

Drupal Module Upgrader takes a Drupal 7 module and attempts to port it to Drupal 8. While it generates files like Drupal Console does, Drupal Console generates module scaffolding and code based on a series of interactive prompts, instead of analyzing an existing module and converting it to work in Drupal 8.

How does Drupal Console compare to Drush?

There are many similarities between these two tools, but the main difference is how it was built, using an object-oriented architecture and Symfony components. Read more about how the tools are similar in these two blog posts:

What kinds of things can you do with Drupal Console?

Drupal Console provides a number of commands for creating module scaffolding and boilerplate code. For any command, you will be asked a series of questions about what you want. In the case of module scaffolding, files are created and inside these files, classes—complete with namespacing and use statements—are created for you with the naming convention you specified in the command's prompts.

Here are some of the code generating commands currently available, or in active development, in Drupal Console:

  • generate:authentication:provider - Generate an Authentication Provider
  • generate:command - Generate commands for the console
  • generate:controller - Generate and Register a controller
  • generate:entity:config - Generate a new EntityConfig object
  • generate:entity:content - Generate a new EntityContent object
  • generate:form:config - Generate a new ConfigFormBase object
  • generate:module - Generate a module
  • generate:permissions - Generate a module permissions object
  • generate:plugin:block - Generate a block plugin
  • generate:plugin:imageeffect - Generate image effect plugin
  • generate:plugin:rest:resource - Generate REST resource plugin
  • generate:service - Generate a service object

Similar to Drush, you can also use Drupal Console to interact with your Drupal 8 installation, or use it for debugging during development. Here are some of the commands currently available (with more in development!):

Clear (rebuild) cache:

  • cache:rebuild - Rebuild and clear all site caches

Configuration Management:

  • config:debug - Show the current configuration
  • config:edit - Edit the selected configuration
  • config:export - Export current application configuration (Note: config:import is planned for development.)
  • config:override - Override config value in active configuration

Container

  • container:debug - Display current services for an application

Migrate (depends on Migrate module)

  • migrate:debug - Display current migration available for the application
  • migrate:execute - Execute a migration available for application

Module

  • module:debug - Display current modules available for application
  • module:download - Install module or modules in the application
  • module:install - Install module or modules in the application
  • module:uninstall - Install module or modules in the application

REST

  • rest:debug - Display current REST resource for the application
  • rest:disable - Disable a REST resource for the application
  • rest:enable - Enable a REST resource for the application

Router

  • router:debug - Display current routes for the application
  • router:rebuild - Rebuild routes for the application

Site

  • site:maintenance - Switch site into maintenance mode
  • site:mode - Switch system performance configuration (Proposed by Joe Shindelar (@eojthebrave) and other Lullabots during DrupalCon Bogotá, this is similar to the Drush devify command.)

Test

  • test:debug - List units-test classes available for the application

Similar to how a module can supply its own Drush commands, modules can also supply custom commands for use in the Drupal Console. Webprofiler is one example of a module that has supplied its own set of Drupal Console commands:

  • webprofiler:benchmark - Benchmark an url
  • webprofiler:export - Export Webprofiler profile/s to file
  • webprofiler:list - List Webprofiler profiles

To learn more about how the Webprofiler project provided integration with Drupal Console, see this blog post by Luca Lusso, Building Bridges - Webprofiler meets Drupal Console.

There are more commands and functionality in the works, and module developers are invited to provide their own custom Drupal Console commands.

Who is the intended audience for the Drupal Console?

Because Drupal Console generates boilerplate code—working example code—for the many different types of entities and objects in Drupal 8 core, this tool can be particularly useful for anyone looking to learn or teach Drupal 8 development. The goal of the project is to make a tool for people learning Drupal 8 that is relatively easy to use.

As such, the following groups in particular could find this tool advantageous to add to their learning Drupal 8 toolkit:

  • Drupal trainers and consultants (providing Drupal 8 developer training)
  • Contributed Drupal 8 module maintainers and developers
  • Drupal development companies (reducing development time for Drupal 8 projects by using the code generation tools)

As mentioned, there are plans to include a non-CLI interface, to make the tool even more accessible to all site administrators of Drupal 8.

Is it ready now? Who can I ask about it?

Yes, and the maintainers invite you to try it out and send them any questions or comments through Twitter at the following accounts: @drupalconsole, @dmouse, @jmolivas, @enzolutions or @omers.

You can download and learn how to set up the project at drupalconsole.com.

What kind of help does the project need?

What features are planned for development?

  • Verbose code output for learning and leveraging docblocks
  • Complete config:import, site:status, and few a few other commands.
  • Import/export content between Drupal installations
  • Site aliases
  • Generate dummy content, probably using PHP Faker library or Default Content project.
  • Add a GUI for Drupal Console as an alternative to the CLI. This could be especially useful for site builders wanting to generate dummy content or issue site commands without needing to use the command line. It could also be used for code generation in the form of a downloadable compressed file.

Additional Resources Mentioned in this Podcast

Project links

Libraries or projects

Blog posts

Bonus!

Check out this Drupal Podcast in Spanish, hosted by Jesus Manuel Olivas and David Flores, two of the maintainers of Drupal Console.

As you can tell, this project is in full swing and looks to be a key resource for Drupal 8 users of all kinds. Listen to the full Drupal Console podcast and give the Drupal Console a spin!

Thanks to Jesus Manuel Olivas for providing a wealth of information and resources about the Drupal Console on the podcast and for this blog post.

Add new comment

Filtered HTML

  • Web page addresses and email addresses turn into links automatically.
  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <code class> <ul type> <ol start type> <li> <dl> <dt> <dd><h3 id> <p>
  • Lines and paragraphs break automatically.

About us

Drupalize.Me is the best resource for learning Drupal online. We have an extensive library covering multiple versions of Drupal and we are the most accurate and up-to-date Drupal resource. Learn more