Answer the question
In order to leave comments, you need to log in
How to make my commands in yii2 console?
Hello!
How to make yii2 see all controllers and actions in a module?
Controllers are in commands.
namespace app\modules\google;
use Yii;
use \yii\base\BootstrapInterface;
/**
* google module definition class
*/
class GoogleModule extends \yii\base\Module implements \yii\base\BootstrapInterface
{
/**
* @inheritdoc
*/
public $controllerNamespace = 'app\modules\google\controllers';
/**
* @inheritdoc
*/
public function init()
{
parent::init();
// custom initialization code goes here
}
public function bootstrap($app)
{
if ($app instanceof \yii\console\Application) {
$this->controllerNamespace = 'app\modules\google\commands';
}
}
}
$config = [
'id' => 'test-console',
'basePath' => dirname(__DIR__),
'bootstrap' => [
'log',
'google',
],
'sourceLanguage'=> 'en',
'language' => 'ru',
'controllerNamespace' => 'app\commands',
'components' => [
'cache' => [
'class' => 'yii\caching\FileCache',
],
'log' => [
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
// 'google' => [
// 'id' => 'google',
// 'class' => 'app\modules\google\GoogleModule',
// ],
// 'urlManager' => [
// 'enablePrettyUrl' => true,
// 'showScriptName' => false,
// 'rules' => [
// 'google/accounts' => 'google/accounts/index',
// ],
// ],
],
'modules' => [
'google' => [
'id' => 'google',
'class' => 'app\modules\google\GoogleModule',
]
],
'params' => $params,
'controllerMap' => [
'google_accounts' => [
'class' => 'app\modules\google\commands\AccountsController',
],
'google_campaigns' => [
'class' => 'app\modules\google\commands\CampaignsController',
],
// 'fixture' => [ // Fixture generation command line.
// 'class' => 'yii\faker\FixtureController',
// ],
],
];
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question