Answers.Body: <blockquote>
    <p>What's the equivalent for registering console commands?</p>
  </blockquote>
  
  <p>You don't need to listen to an event to create a console command. Assuming your namespacing and autoloading is set up correctly, they'll "just work".</p>
  
  <p>I'd suggest going over to <a href="https://pluginfactory.io/" rel="nofollow noreferrer">https://pluginfactory.io/</a> and select with Craft 3 plugin or module and tick the "Console Commands" checkbox to see a working example of how the files and structure is set up.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-21T23:38:50.273Z
Answers.Text: Perfect, thanks for the tip! I looked at the fantastic SEO plugin to see the correct structure (https://github.com/ethercreative/seo/blob/v3/src/console/controllers/UpgradeController.php).
Answers.UserDisplayName: Mike
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-20T00:40:52.743Z
Answers.LastActivityDate: 2019-01-20T00:40:52.743Z
Answers.UserDisplayName: Brad Bell
Body: <p>I would like to create a custom console command for my Craft 3 plugin. I've looked at the Yii docs and understand commands are defined using controllers extending <code>\yii\console\Controller</code> but cannot work out how these controllers should be registered with the application.</p>
  
  <p>To register site routes in Craft 3, we listen for the <code>UrlManager::EVENT_REGISTER_SITE_URL_RULES</code> event and then define rules. What's the equivalent for registering console commands?</p>
  
  <p>Thanks</p>
  
Tags: <plugin-development><craft3><modules><yii><console>
Title: How do I create console commands for my module or plugin?
ThreadText: # How do I create console commands for my module or plugin?
  
  (Asked by: username_0 on 2019-01-17)
  
  I would like to create a custom console command for my Craft 3 plugin. I've looked at the Yii docs and understand commands are defined using controllers extending `\yii\console\Controller` but cannot work out how these controllers should be registered with the application.
  
  To register site routes in Craft 3, we listen for the `UrlManager::EVENT_REGISTER_SITE_URL_RULES` event and then define rules. What's the equivalent for registering console commands?
  
  Thanks
  
  **Tags:** plugin-development, craft3, modules, yii, console
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-01-20. Score: 1 | Accepted answer
  
  > What's the equivalent for registering console commands?
  
  You don't need to listen to an event to create a console command. Assuming your namespacing and autoloading is set up correctly, they'll "just work".
  
  I'd suggest going over to <https://pluginfactory.io/> and select with Craft 3 plugin or module and tick the "Console Commands" checkbox to see a working example of how the files and structure is set up.
  
  > **Comments:**
  > **username_0**: Perfect, thanks for the tip! I looked at the fantastic SEO plugin to see the correct structure (https://github.com/ethercreative/seo/blob/v3/src/console/controllers/UpgradeController.php).  
  
  ---
  
  