1

I found the documentation here very confusing: https://craftcms.com/docs/3.x/extend/commands.html#module-setup

I've scaffolded a simple test plugin from https://pluginfactory.io/ with "Console Commands" enabled and I've pulled my plugin into composer via 'path'. The plugin shows up fine in the Craft UI, and so I installed it.

However, I can't get the new command to display in the terminal when I do a 'php craft'. Am I supposed to see it?

1
  • Maybe there is something missing. I would also suggest you to take a look on some popular plugins and how they implemented custom commands.
    – Johannes
    Commented Apr 5, 2021 at 7:54

1 Answer 1

1

You should see your commands when using the Craft CLI.

First thing to check would be that the module is registered in app.php, both in the modules and bootstrap arrays. Craft's documentation on that is here.

I find the best way to quickly validate that your module is registered, is by dumping something out from the module init() function. Craft::dd('Registered') does the trick. If you don't see anything on the frontend, your module isn't getting loaded into Craft.

Secondly, I would check that you are correctly setting the controllerNamespace, so that Craft knows where to look for controllers, depending on your request. Their documentation on that is here.

Finally, check that you have some valid functions setup in your controllers. Each function name should be prefixed with action. For example: actionRun() in a JobController.php file will be run with php craft mymodule/job/run.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.