M
M
Maxim2018-10-05 03:35:30
Yii
Maxim, 2018-10-05 03:35:30

Yii2 how to connect console commands in a module?

Hello!
1. I placed the console commands in the module backend\modules\event\commands
2. I connected the commands in the module:

/**
     * @inheritdoc
     */
    public function init()
    {
        parent::init();
        if (Yii::$app instanceof \yii\console\Application) {
            $this->controllerNamespace = 'backend\modules\event\commands';
        }
    }

3. How now to access these commands using the advanced application? After all, using the path site.ru/yii module/controller/action I get to the folder console, instead 'backend\modules\event\commands'
of I need to create in the backend a file similar to yii.php yii_backend.php in which I will place
$application = new yii\console\Application($config);
$exitCode = $application->run();
exit($exitCode);
and contact him? Tell me please!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2018-10-05
@myks92

Good morning.
If you open the yii file, you will see that it is almost identical to the index file in the web directory.
This means that you can move it to the right place, change the paths to the configuration files and run it)))
Here is an article that will help you.
Article for yii1, but I think you will understand the idea.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question