file commands / FlagController.php namespace app \ commands;
use yii;
use yii\console\Controller;
use yii\base\Component;
use app\components\flag\AbstractFlagService;
use app\components\flag\FlagService;
class FlagController extends Controller
{
public function actionCheck()
{
$flagService = \Yii::$app->get('flag-service');
if(Yii::$app->flag->run()) {
echo true;
}
}
}
设置\ console.php
<?php use \yii\console\controllers\MigrateController;
$config = [
'id' => 'basic-console',
'controllerNamespace' => 'app\commands',
'components' => [
'flag' => [
'class' => 'app/components/flag/FlagService',
]
],
];
if (YII_ENV_DEV) {
$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = [
'class' => 'yii\gii\Module',
];
}
我有一个错误异常&#39; ReflectionException&#39;消息&#39; Class app / components / flag / FlagService不存在&#39;。如何在yii2上使用控制台应用程序中的app-component