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

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

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

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