Error: Class 'Yii\web\Response' not found

I have “Error: Class ‘Yii\web\Response’ not found”. The error occurs only for a few customers. I use the full path to the class so it should not be a problem. If there was a problem with files, everyone would have such a error. I already have no ideas for a solution. Maybe someone has already encountered such a problem?

Would you please provide a full error info including stacktrace?

Error: Class ‘Yii\web\Response’ not found in /xxxxxxxxxxxxxxxx/controllers/XxxxxxxController.php:160
Stack trace:
#0 [internal function]: app\controllers\XxxxxxxController->actionXxxxx()
#1 /xxxxxxxxxxxxxxxx/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#2 /xxxxxxxxxxxxxxxx/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#3 /xxxxxxxxxxxxxxxx/vendor/yiisoft/yii2/base/Module.php(528): yii\base\Controller->runAction(‘xxxxx’, Array)
#4 /xxxxxxxxxxxxxxxx/vendor/yiisoft/yii2/web/Application.php(103): yii\base\Module->runAction(‘xxxxxxx/xxxxx’, Array)
#5 /xxxxxxxxxxxxxxxx/vendor/yiisoft/yii2/base/Application.php(386): yii\web\Application->handleRequest(Object(yii\web\Request))
#6 /xxxxxxxxxxxxxxxx/web/index.php(12): yii\base\Application->run()
#7 {main}

Method with error:

public function actionXxxxxx($xx)
Yii::$app->response->format = yii\web\Response::FORMAT_JSON; //line with error

return $wynik;

Interesting. Would you please try

public function actionXxxxxx($xx)
Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; //line with error

I will try but only a few users have this problem. I have to wait for their entry. At first it seemed to apply to old systems, i.e. Windows XP and Android 4.4, but one person reports that he is using Windows 10 and also has such a problem. About 1% of users have a problem. For now, I solved it like this:

Yii::$app->response->format = yii\web\Response::FORMAT_JSON;

echo json_encode($responseData);
return $responseData;