Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error when installed Yii2

Tags:

php

yii2

I've install Yii2 framework using composer but get this error in my browser (on localhost):

Invalid Configuration – yii\base\InvalidConfigException

yii\web\Request::cookieValidationKey must be configured with a secret key.

How can I solve this problem?

like image 422
Nikita Avatar asked Aug 08 '16 08:08

Nikita


3 Answers

There is this problem with basic app now https://github.com/yiisoft/yii2-app-basic/issues/69 where composer install doesn't generate this key.

You need to add this key manually.

  1. Go to /config/web.php.
  2. Edit the line 'cookieValidationKey' => '', to include random string (you can use anything like 'cookieValidationKey' => 'jfsbkjsbfdskjgfdskjbgfsdhjgfajds',
like image 113
Bizley Avatar answered Oct 20 '22 07:10

Bizley


You need to set cookieValidationKey in the config file to a random string. The config file is located under yii/your-projectfolder/config/main-local.php if you are using Yii 2.0 Advanced Template

like image 37
Jason Avatar answered Oct 20 '22 09:10

Jason


enter image description here

You need to set cookieValidationKey value in project/config/web.php at line 12.

change at:

'cookieValidationKey' => '',

replace with:

'cookieValidationKey' => 'setyourkey',

enter image description here

That should address the issue.

like image 42
yekyawaung Avatar answered Oct 20 '22 07:10

yekyawaung