0.背景
搭建yii2框架时,最后一步运行php yii serve.
然后访问localhost:8080,然后就开始报错:
yii\web\Request::cookieValidationKey must be configured with a secret key.
1.解决办法
打开我们yii2框的目录,找到config/web.php。然后找到下面代码:
'request' => [
// !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
'cookieValidationKey' => '123456',
],
原来cookieValidationKey的值是空,给他改成一个非空值就可以,我测试过true,123456,asdf等字符串,均能正常打开页面,
正常打开网站是下面这样: