Why are there 2 APP keys in Laravel? .Env and config / app.php

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

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

My questions about newbies:

1) Why are there application keys in two different places?

2) When the application key was created, why didn’t it config/app.php ?

3) Do I need to manually insert the .env App key into the config/app.php or will this be optional if .env is there?

4) During future updates, do I need to continue to add the application key to the app.php file? So it will be reset during updates?

+5
source share
1 answer

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

+8
source

All Articles