[font="Tahoma"]hi
i’m trying to call a frontend action from console like
php yii cron/test
console action is like
public function actionTest(){
yii::$app->controllerNamespace = "frontend\controllers";
$test = Yii::$app->runAction('web-service/test', [
]);
echo $test;
}
frontend action is like:
public function beforeAction($action)
{
if ($action->id == 'test') {
$this->enableCsrfValidation = false;
}
return parent::beforeAction($action);
}
function actionTest(){
$x="hi ";
echo $x;
return $x;
}
in command prmpot i get result like this
hi 0 // i have really tested this codes
“hi” is because of echo in actionTest but i can’t understand why printed $test in console is 0?
it seems “return $x” won’t work and $x is not returned to console action.
if i move frontend action to somewhere like component (of course with changes like removing beforeaction() and calling component instead of runaction), i get expected result "hi hi".[/font]