Is It Possible To Run Commands From A Different Location Than App/commands?

For instance, in a module or a package?

Answer: You can run commands in modules. BUT the module must be defined in your config, and you technically run controllers.

Example:




'modules' => [

    'mymodule' => [

        'class' => 'app\modules\mymodule\Module',

        ...params...

    ]

]



Then, you can run commands via the app/modules/mymodule/controllers directory.




app/modules/mymodule/controllers/TestController.php


$ php yii mymodule/test