Console command error: Exception yii\console\Request::validateCsrfToken()

Hello community,

I have followed this receipt to create a Yii console command:
https://www.yiiframework.com/wiki/820/yii2-create-console-commands-inside-a-module-or-extension

But when I run it, I get this error in command line:

local% ./yii imports_exports/exports/exports
Exception 'yii\base\UnknownMethodException' with message 'Calling unknown method: yii\console\Request::validateCsrfToken()'

Why? I double checked my code and can’t find any mistake.

I found it: changed “yii/web/Controller” to “yii/console/Controller”.
My mistake.

4 Likes