35 Reasons to Use Console for Your Drupal 8 Development

35 Reasons to Use Console for Your Drupal 8 Development

default avatar
Pensé parRay Saltini
Avril 03, 2015
FFW Blog - illustration

The Drupal Console is a suite of tools that you run on a command line interface to generate boilerplate code and interact with a Drupal 8 installation. Go to this post for more information about the project. Currently it features 35 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

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

Additional Resources

Project links

Libraries or projects

Blog posts

Spanish Language Podcast

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

FFW Drupal 8 Solutions Engineer Jesus Manuel Olivas (@jmolivas) provided a wealth of information and resources for this post. Thanks also goes out to drupalize.me and Amber Matz for their great podcast about the Drupal Console project. We've reused much of their podcast notes for this post. We're grateful for their support. Please be sure to listen to the podcast!

Editied by Ray Saltini, FFW Drupal Evangelist