Why is there 2 APP Key in Laravel? .env and config/app.php

こ雲淡風輕ζ 提交于 2019-12-22 06:29:59

问题


I installed Laravel 5 via composer and after the installation the App Key was generated automatically. I went to .env file and I could see the APP_KEY there. However, I also noticed that there is another APP_KEY inside config/app.php like this:

'key' => env('APP_KEY', 'SomeRandomString'),
'cipher' => 'AES-256-CBC',

My newbie questions are:

1) Why is there App keys in 2 different locations?

2) When App Key was generated, why didnt it update the config/app.php file as well?

3) Do I need to manually paste the .env App key into the config/app.php file too or will that be not necessary as long as .env has it there?

4) During future updates, do I need to keep adding the App key into app.php file? Meaning, would it get reseted during updates?


回答1:


The value set in config/app.php is used if there is no value in the .env file. If you have set the app key in the .env file, the second argument in app.php is ignored.



来源:https://stackoverflow.com/questions/31228294/why-is-there-2-app-key-in-laravel-env-and-config-app-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!