Reputation: 1104
In Laravel 6 Documentation second paragraph of Application Key
written like this
Typically, this string should be 32 characters long. The key can be set in the .env environment file. If you have not renamed the
.env.example
file to.env
, you should do that now. If the application key is not set, your user sessions and other encrypted data will not be secure!
Why did they ask to rename it? I also found this paragraph in the Laravel older version. Is there any difference between those since they have the same content but different name?
Upvotes: 3
Views: 3258
Reputation: 10091
The .env.example
the file is just an example of the .env
file. It is not used by the app. It is used to serve as a base for you to edit and rename.
In a fresh Laravel installation, the root directory of your application will contain a .env.example
file. If you install Laravel via Composer, this file will automatically be renamed to .env
. Otherwise, you should rename the file manually.
Upvotes: 0
Reputation: 240
The simplest way is move it on your server
with Filezilla
or another FTP program. Rename file
, and re-download
it on your computer
. It works for me last time :)
Upvotes: 0
Reputation: 15306
If you've install Laravel using composer command.
composer create-project laravel/laravel projectname
you don't need renamed the .env.example
file to .env
. If you installed Laravel via Composer or the Laravel installer, this key has already been set for you by the php artisan key:generate
command.
If you clone project using git clone
some folder is ignored by git so you might not get env file as well as vendor folder. Therefore, they will have to manually enter php artisan key:generate
for their app to function correctly.
Upvotes: 4
Reputation: 58
Laravel need to use .env
file to define a database connection, some general setting like application key
as well. So if you have no .env
file, your Laravel has not a setting for now.
Like they said, If the application key is not set, your user sessions and other encrypted data will not be secure!
You need to create / copy /remove the .env.example
to the new .env
for this reason. for letting our Laravel knows about general config.
By the way, do not use the .env.example
like copy-and-paste because it's an example. you need to change the value config to your own.
Upvotes: 1