3

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?

Udhav Sarvaiya
  • 9,380
  • 13
  • 53
  • 64
Aditya
  • 1,075
  • 1
  • 14
  • 24
  • if you already have an `.env` file you don't need to rename the `.env.example` file. they are identical at the very beginning. if you don't have an `.env` file, in that case you have to rename it to `.env` as your application environment will be loaded from `.env` file. – zahid hasan emon Sep 26 '19 at 05:07

4 Answers4

4

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.

More info SO answer

Dilip Hirapara
  • 14,810
  • 3
  • 27
  • 49
1

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.

0

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.

Udhav Sarvaiya
  • 9,380
  • 13
  • 53
  • 64
0

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 :)

Suvin94
  • 283
  • 9
  • 30