I have just encountered the same error message. In my case the problem was when turning on I18n by means of Yii::t. It turned out that Gii somehow does not add leading "\" when generating a model template, namely public function attributeLabels()
method. I changed
return [
'id' => \Yii::t('app', 'ID'),
'fullName' => \Yii::t('app', 'Full Name'),
];
to
return [
'id' => \Yii::t('app', 'ID'),
'fullName' => \Yii::t('app', 'Full Name'),
];
and the error disappeared. Try to do the same.