我的yii2模板是:yii-basic-app-2.0.10.tgz,解壓到當前文件夾進行使用;
運行時出現如下錯誤:
Invalid Configuration – yii\base\InvalidConfigExceptionyii\web\Request::cookieValidationKey must be configured with a secret key.
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
解決方法:
打開文件config\web.PHP, 設置 'cookieValidationKey' => 'true',即可,如;
$config = [
'id' => 'basic',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'components' => [
'request' => [
// !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
'cookieValidationKey' => 'true', // 就是這裏了
],
'cache' => [
'class' => 'yii\caching\FileCache',
],