How do I create console commands for my module or plugin? 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
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.