为什么Laravel中有2个APP Key? .env和config/app.php [英] Why is there 2 APP Key in Laravel? .env and config/app.php
问题描述
我通过作曲家安装了Laravel 5,并在安装后自动生成了App Key.我转到了.env
文件,在那里可以看到APP_KEY.但是,我还注意到config/app.php
中还有另一个APP_KEY,如下所示:
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',
我的新手问题是:
1)为什么在两个不同的位置都有App键?
1) Why is there App keys in 2 different locations?
2)生成应用程序密钥时,为什么还不更新config/app.php
文件?
2) When App Key was generated, why didnt it update the config/app.php
file as well?
3)我是否还需要手动将.env
应用程序密钥粘贴到config/app.php
文件中,还是只要.env
那里没有它是没有必要的?
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)在将来的更新过程中,是否需要继续将App密钥添加到app.php文件中?意思是,它会在更新期间重置吗?
4) During future updates, do I need to keep adding the App key into app.php file? Meaning, would it get reseted during updates?
推荐答案
如果.env
文件中没有值,则使用在config/app.php
中设置的值.如果您已在.env
文件中设置了应用程序密钥,则app.php
中的第二个参数将被忽略.
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.
这篇关于为什么Laravel中有2个APP Key? .env和config/app.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!