Guys,
I’ve got this annoying problem - I’ve created module Test and prepared the console controller inside it. Now when calling from command line
yii help
it shows my tool like this
...
... default yii commands ...
...
- test Test command line tool.
test/test/check Checks Test.
test/test/index (default)
The thing is with the double "test" here.
I can use
yii help test/check
and I get
DESCRIPTION
Checks Test.
USAGE
yii test/test/check [...options...]
....
but not
yii help test/test/check
because
Error: No help for unknown sub-command "test/test/test/check".
with even triple "test".
As you can see above yii help test/check gives me usage command yii test/test/check which is not recognised but I can use
yii test/check
and it works fine.
How to remove the double "test"? Or at least how to make it consistent for help tool suggestions and actual commands?
Module:
<?php
namespace mymodules\test;
use Yii;
use yii\base\BootstrapInterface;
use yii\base\Module as BaseModule;
class Module extends BaseModule implements BootstrapInterface
{
public $controllerNamespace = 'mymodules\test\controllers';
public function bootstrap($app)
{
if ($app instanceof \yii\console\Application) {
$app->controllerMap[$this->id] = [
'class' => 'mymodules\test\console\ToolController',
'module' => $this
];
}
}
}
Controller:
<?php
namespace mymodules\test\console;
use yii\console\Controller;
use yii\helpers\Console;
/**
* Test command line tool.
*
*/
class ToolController extends Controller
{
public function actionIndex()
{
$this->run('/help', ['test']);
}
/**
* Checks Test.
*/
public function actionCheck()
{
$this->stdout("\nTest check\n");
$this->stdout("------------------------------\n");
}
}