migrate/up 中的异常 'yii\base\UnknownPropertyException'

Exception 'yii\base\UnknownPropertyException' in migrate/up

我想使用 yii2-forms extension 但我在迁移时遇到问题。

这是迁移过程中的错误。

C:\xampp\htdocs\SEPreport>yii migrate/up --migrationPath=@vendor/pceuropa/yii2-forms/migrations
Exception 'yii\base\UnknownPropertyException' with message 'Setting unknown property: yii\console\Request::enableCsrfValidation'

in C:\xampp\htdocs\SEPreport\vendor\yiisoft\yii2\base\Component.php:209

Stack trace:
#0 C:\xampp\htdocs\SEPreport\vendor\yiisoft\yii2\BaseYii.php(546): yii\base\Component->__set('enableCsrfValid...', false)
#1 C:\xampp\htdocs\SEPreport\vendor\yiisoft\yii2\base\BaseObject.php(107): yii\BaseYii::configure(Object(yii\console\Request), Array)
#2 [internal function]: yii\base\BaseObject->__construct(Array)
#3 C:\xampp\htdocs\SEPreport\vendor\yiisoft\yii2\di\Container.php(383): ReflectionClass->newInstanceArgs(Array)
#4 C:\xampp\htdocs\SEPreport\vendor\yiisoft\yii2\di\Container.php(156): yii\di\Container->build('yii\console\Req...', Array, Array)
#5 C:\xampp\htdocs\SEPreport\vendor\yiisoft\yii2\BaseYii.php(349): yii\di\Container->get('yii\console\Req...', Array, Array)
#6 C:\xampp\htdocs\SEPreport\vendor\yiisoft\yii2\di\ServiceLocator.php(137): yii\BaseYii::createObject(Array)
#7 C:\xampp\htdocs\SEPreport\vendor\yiisoft\yii2\base\Module.php(742): yii\di\ServiceLocator->get('request', true)
#8 C:\xampp\htdocs\SEPreport\vendor\yiisoft\yii2\console\Application.php(219): yii\base\Module->get('request')
#9 C:\xampp\htdocs\SEPreport\vendor\yiisoft\yii2\base\Application.php(386): yii\console\Application->getRequest()
#10 C:\xampp\htdocs\SEPreport\yii(27): yii\base\Application->run()
#11 {main}

我还在 frontendbackend:

中设置了 enableCsrfValidation
'components' => [
        'request' => [
            'enableCsrfValidation' => false, // I set it to true too
            'enableCookieValidation' => false,
        ],
]

请帮助我。我需要做什么来解决它?

如果您将特定于 Web 的设置放入 consolecommon 配置文件中,您可能会遇到此类错误。控制台Request没有enableCsrfValidation属性,所以抛出yii\base\UnknownPropertyException异常。

如果您想配置特定于 Web 的设置,您应该在 backend/config/main.php and/or frontend/config/main.php.

中执行此操作