Skip to main content

Drupal Code Generator Cheatsheet

Drupal Code Generator Cheatsheet (3.6.1)

Now Drupal Console has been officially deprecated lets have a look at the array of available commands available to Drush users using the in built Drupal Code Generator.

$drush generate

Drupal Code Generator 3.6.1

Run `drush generate [command]` and answer a few questions in order to write starter code to your project.

Available commands:                                                                  
_global:                                                                             
  composer (composer.json)                        Generates a composer.json file     
  controller                                      Generates a controller             
  field                                           Generates a field                  
  hook                                            Generates a hook                   
  install-file                                    Generates an install file          
  javascript                                      Generates Drupal JavaScript file   
  layout                                          Generates a layout                 
  module                                          Generates Drupal module            
  phpstorm-meta                                   Generates PhpStorm metadata        
  readme                                          Generates README file              
  render-element                                  Generates Drupal render element    
  service-provider                                Generates a service provider       
  single-directory-component (sdc)                Generates Drupal SDC theme         
                                                  component                          
drush:                                                                               
  drush:alias-file (daf)                          Generates a Drush site alias file. 
  drush:command-file (dcf)                        Generates a Drush command file.    
  drush:symfony-command (symfony-command)         Generates Symfony console command  
entity:                                                                              
  entity:bundle-class (bundle-class)              Generate a bundle class for a      
                                                  content entity.                    
  entity:configuration (config-entity)            Generates configuration entity     
  entity:content (content-entity)                 Generates content entity           
form:                                                                                
  form:config (config-form)                       Generates a configuration form     
  form:confirm (confirm-form)                     Generates a confirmation form      
  form:simple (form)                              Generates simple form              
misc:                                                                                
  misc:apache-virtual-host (apache-virtual-host)  Generates an Apache site           
                                                  configuration file                 
  misc:nginx-virtual-host (nginx-virtual-host)    Generates an Nginx site            
                                                  configuration file                 
plugin:                                                                              
  plugin:action (action)                          Generates action plugin            
  plugin:block (block)                            Generates block plugin             
  plugin:ckeditor (ckeditor, ckeditor-plugin)     Generates CKEditor plugin          
  plugin:condition (condition)                    Generates condition plugin         
  plugin:constraint (constraint)                  Generates constraint plugin        
  plugin:entity-reference-selection               Generates entity reference         
(entity-reference-selection)                      selection plugin                   
  plugin:field:formatter (field-formatter)        Generates field formatter plugin   
  plugin:field:type (field-type)                  Generates field type plugin        
  plugin:field:widget (field-widget)              Generates field widget plugin      
  plugin:filter (filter)                          Generates filter plugin            
  plugin:manager                                  Generates plugin manager           
  plugin:menu-link (menu-link)                    Generates menu-link plugin         
  plugin:migrate:destination                      Generates migrate destination      
(migrate-destination)                             plugin                             
  plugin:migrate:process (migrate-process)        Generates migrate process plugin   
  plugin:migrate:source (migrate-source)          Generates migrate source plugin    
  plugin:queue-worker (queue-worker)              Generates queue worker plugin      
  plugin:rest-resource (rest-resource)            Generates rest resource plugin     
  plugin:views:argument-default                   Generates views default argument   
(views-argument-default)                          plugin                             
  plugin:views:field (views-field)                Generates views field plugin       
  plugin:views:style (views-style)                Generates views style plugin       
service:                                                                             
  service:access-checker (access-checker)         Generates an access checker        
                                                  service                            
  service:breadcrumb-builder (breadcrumb-builder) Generates a breadcrumb builder     
                                                  service                            
  service:cache-context (cache-context)           Generates a cache context service  
  service:custom (custom-service)                 Generates a custom Drupal service  
  service:event-subscriber (event-subscriber)     Generates an event subscriber      
  service:logger (logger)                         Generates a logger service         
  service:middleware (middleware)                 Generates a middleware             
  service:param-converter (param-converter)       Generates a param converter        
                                                  service                            
  service:path-processor (path-processor)         Generates a path processor service 
  service:request-policy (request-policy)         Generates a request policy service 
  service:response-policy (response-policy)       Generates a response policy        
                                                  service                            
  service:route-subscriber (route-subscriber)     Generates a route subscriber       
  service:theme-negotiator (theme-negotiator)     Generates a theme negotiator       
  service:twig-extension (twig-extension)         Generates Twig extension service   
  service:uninstall-validator                     Generates a uninstall validator    
(uninstall-validator)                             service                            
test:                                                                                
  test:browser (browser-test)                     Generates a browser based test     
  test:kernel (kernel-test)                       Generates a kernel based test      
  test:nightwatch (nightwatch-test)               Generates a nightwatch test        
  test:unit (unit-test)                           Generates a unit test              
  test:webdriver (webdriver-test)                 Generates a test that supports     
                                                  JavaScript                         
theme:                                                                               
  theme                                           Generates Drupal theme             
  theme:settings                                  Generates Drupal                   
                                                  theme-settings.php file            
yml:                                                                                 
  yml:breakpoints (breakpoints)                   Generates a breakpoints yml file   
  yml:links:action (action-links)                 Generates a links.action yml file  
  yml:links:contextual (contextual-links)         Generates links.contextual yml     
                                                  file                               
  yml:links:menu (menu-links)                     Generates a links.menu yml file    
  yml:links:task (task-links)                     Generates a links.task yml file    
  yml:migration (migration, migration.yml)        Generates a migration yml file     
  yml:module-libraries (module-libraries)         Generates module libraries yml     
                                                  file                               
  yml:permissions (permissions, permissions.yml)  Generates a permissions yml file   
  yml:routing (routing, routing.yml)              Generates a routing yml file       
  yml:services (services, services.yml)           Generates a services yml file      
  yml:theme-libraries (theme-libraries)           Generates theme libraries yml file 

Add new comment

Filtered HTML

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