yii2 - How can I tell if I am in 'console' mode -
i writing app runs browser. however, model functions called yii2 console. therefore, getting errors when trying access variables set in gui.
is possible tell mode in? there environment variable automatically set, or should set session variable in console app indicate state?
thanks in advance,
martin
you can use
if(is_a(yii::$app,'yii\console\application'))
for console, and
if(is_a(yii::$app,'yii\web\application'))
for web.
Comments
Post a Comment