There is no problem not worth solving, and no technology not worth learning!

After executing the init command in yii2, an error is reported: yii\web\request::cookieValidationKey must be configured with a secret key.

在 Yii2 中执行 init 命令后,报错:yii\web\Request::cookieValidationKey must be configured with a secret key.

1. After executing the init command in yii2, an error is reported: yii\web\request::cookieValidationKey must be configured with a secret key. as shown in Figure 1

在 Yii2 中执行 init 命令后,报错:yii\web\Request::cookieValidationKey must be configured with a secret key.
Figure 1

2. I finally decided to improve a set of files in the environments directory, because this is a new copy of the application. When generating cookie validation key in , it is determined that it is a missing domain namehttps://tougao.apply.localThe corresponding file generate cookie validation key in papersubmission/config/main-local.php. as shown in Figure 2

最终决定完善一下 environments 目录下的一组文件,因为这是一个复制的新的应用。在 generate cookie validation key in 时,确定是遗漏域名 https://tougao.apply.local 所对应的 文件  generate cookie validation key in papersubmission/config/main-local.php
Figure 2

PS C:\wwwroot\apply-server\src> ./init
Yii Application Initialization Tool v1.0

Which environment do you want the application to be initialized in?

  [0] Development
  [1] Production

  Your choice [0-1, or "q" to quit] 0

  Initialize the application under 'Development' environment? [yes|no] yes

  Start initialization ...

      exist api/config/main-local.php
            ...overwrite? [Yes|No|All|Quit] All
  overwrite api/config/main-local.php
  unchanged api/config/params-local.php
  unchanged backend/config/codeception-local.php
  overwrite backend/config/main-local.php
  unchanged backend/config/params-local.php
  unchanged backend/config/test-local.php
  unchanged backend/web/index-test.php
  unchanged backend/web/index.php
  unchanged backend/web/robots.txt
  overwrite common/config/codeception-local.php
  overwrite common/config/main-local.php
  overwrite common/config/params-local.php
  unchanged common/config/test-local.php
  unchanged console/config/main-local.php
  unchanged console/config/params-local.php
  unchanged console/config/test-local.php
  unchanged frontend/config/codeception-local.php
  overwrite frontend/config/main-local.php
  unchanged frontend/config/params-local.php
  unchanged frontend/config/test-local.php
  unchanged frontend/web/index-test.php
  unchanged frontend/web/index.php
  unchanged frontend/web/robots.txt
  overwrite management/config/main-local.php
  unchanged management/config/params-local.php
  unchanged papersubmission/config/main-local.php
  unchanged papersubmission/config/params-local.php
  unchanged yii
  unchanged yii_test
  unchanged yii_test.bat
   generate cookie validation key in backend/config/main-local.php
   generate cookie validation key in common/config/codeception-local.php
   generate cookie validation key in frontend/config/main-local.php
   generate cookie validation key in management/config/main-local.php
   generate cookie validation key in api/config/main-local.php
      chmod 0777 backend/runtime
      chmod 0777 backend/web/assets
      chmod 0777 console/runtime
      chmod 0777 frontend/runtime
      chmod 0777 frontend/web/assets
      chmod 0777 api/runtime
      chmod 0777 api/web/assets
      chmod 0777 management/runtime
      chmod 0777 management/web/assets
      chmod 0755 yii
      chmod 0755 yii_test

  ... initialization completed.


3. Copy /environments/dev/frontend to /environments/dev/paperSubmission , copy /environments/prod/frontend to /environments/prod/paperSubmission , and then edit /environments/index.php , and add the configuration items related to PaperSubmission . as shown in Figure 3

复制 /environments/dev/frontend 至 /environments/dev/papersubmission ,复制 /environments/prod/frontend 至 /environments/prod/papersubmission ,然后编辑 /environments/index.php ,在其中添加 papersubmission 相关的配置项
Figure 3

4. After executing the init command again in yii2, an error will not be reported.

PHP / Laravel / Yii2 Legacy Project Maintenance & Long-Term Technical Support

If your PHP / Laravel / Yii2 project is already in production but needs bug fixing, API troubleshooting, performance optimization, developer handover support, or long-term maintenance, feel free to contact me for remote technical support.

Ideal For:
✅ PHP legacy systems without active maintenance
✅ Laravel / Yii2 project bug fixes
✅ Admin panel feature iterations
✅ RESTful API troubleshooting
✅ MySQL / Redis / Nginx performance issues
✅ Long-term remote part-time maintenance

We can start with a small task:
✅ Production error troubleshooting
✅ API issue analysis
✅ Slow query and performance bottleneck diagnosis
✅ Initial code structure review
✅ Deployment environment and log inspection

If you would like to discuss your project, please contact me and mention: PHP Maintenance Consultation.

Contact Me:
Telegram: @shuijingwan
WeChat: 13980074657
Email: shuijingwanwq@gmail.com

评论

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.