How to install drupal console and generate boilerplate drupal module code.

By toswebdev, 20 May, 2022
How to install drupal console and generate boilerplate drupal module code.

What is Drupal Console?

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

Drupal Console Installation using Composer 

Run Below Command to install the Drupal console in your project please make sure your drupal instance install using composer.

composer require drupal/console:~1.0 \

--prefer-dist \

--optimize-autoloader

Once Install the Drupal console then you have just run the below command to generate the boilerplate code.

 

Command ( Short CMD ) Meaning 
drupal generate:ajax:command (gac) Generate & Register a custom ajax command
drupal generate:authentication:provider (gap) Generate an Authentication Provider
drupal generate:block:type (gbt) Generate a block content type
drupal generate:breakpoint (gb) Generate breakpoint
drupal generate:cache:context (gcc) Generate a cache context
drupal generate:command (gco) Generate commands for the console.
drupal generate:composer (gcom) Generate a composer.json file
drupal generate:controller (gcon) Generate & Register a controller
drupal generate:entity:bundle (geb) Generate a new content type (node / entity bundle)
drupal generate:entity:config (gec) Generate a new config entity
drupal generate:entity:content (geco) Generate a new content entity
drupal generate:event:subscriber (ges) Generate an event subscriber
generate:form (gf) Generate a new "FormBase"
drupal generate:form:alter (gfa) Generate an implementation of hook_form_alter() or hook_form_FORM_ID_alter
drupal generate:form:config (gfc) Generate a new "ConfigFormBase"
drupal generate:help (gh) Generate an implementation of hook_help()
drupal generate:jstest (gjt) Generate a JavaScript test.
drupal generate:module (gm) Generate a module.
drupal generate:module:file (gmf) Generate a .module file
drupal generate:permissions (gp) Generate module permissions
drupal generate:plugin:block (gpb) Generate a plugin block
drupal generate:plugin:ckeditorbutton (gpc) Generate CKEditor button plugin.
drupal generate:plugin:condition (gpco) Generate a plugin condition.
drupal generate:plugin:derivative (gpd) commands.generate.derivative.description
drupal generate:plugin:field (gpf) Generate field type, widget and formatter plugins.
drupal generate:plugin:fieldformatter (gpff) Generate field formatter plugin.
drupal generate:plugin:fieldtype (gpft) Generate field type plugin.
drupal generate:plugin:fieldwidget (gpfw) Generate field widget plugin.
drupal generate:plugin:imageeffect (gpie) Generate image effect plugin.
drupal generate:plugin:imageformatter (gpif) Generate image formatter plugin.
drupal generate:plugin:mail (gpm) Generate a plugin mail
drupal generate:plugin:migrate:dataparser (gpmdp) Generate a migrate data parser
drupal generate:plugin:migrate:process (gpmp) Generate a migrate process plugin
drupal generate:plugin:migrate:source (gpms) Generate a migrate source plugin
drupal generate:plugin:queue (gpqueue) Drupal Console Queueworker generator.
drupal generate:plugin:rest:resource (gprr) Generate plugin rest resource
drupal generate:plugin:rules:action (gpra) Generate a plugin rule action
drupal generate:plugin:rules:dataprocessor (gprd) Generate a plugin rule dataprocessor
drupal generate:plugin:skeleton (gps) Generate an implementation of a skeleton plugin
drupal generate:plugin:type:annotation (gpta) Generate a plugin type with annotation discovery
drupal generate:plugin:type:yaml (gpty) Generate a plugin type with Yaml discovery
drupal generate:plugin:validationconstraint (gpvc) Generate a validation constraint plugin.
drupal generate:plugin:views:field (gpvf) Generate a custom plugin view field.
drupal generate:post:update (gpu) Generate an implementation of hook_post_update_NAME()
drupal generate:profile (gpr) Generate a profile.
drupal generate:routesubscriber (gr) Generate a RouteSubscriber
drupal generate:service (gs) Generate service
drupal generate:site:alias (gsa)  Generates a site alias.
drupal generate:theme (gt) Generate a theme.
drupal generate:theme:setting (gts) Generate a setting configuration theme
drupal generate:twig:extension (gte) Generate a Twig extension.
drupal generate:update (gu) Generate an implementation of hook_update_N()

Comments

All comments go through moderation, so your comment won't display immediately.