How to generate .env file for laravel? How to generate .env file for laravel? laravel laravel

How to generate .env file for laravel?


Just tried both ways and in both ways I got generated .env file:

enter image description here

Composer should automatically create .env file. In the post-create-project-cmd section of the composer.json you can find:

"post-create-project-cmd": [  "php -r \"copy('.env.example', '.env');\"",  "php artisan key:generate"]

Both ways use the same composer.json file, so there shoudn't be any difference.

I suggest you to update laravel/installer to the last version: 1.2 and try again:

composer global require "laravel/installer=~1.2"

You can always generate .env file manually by running:

cp .env.example .envphp artisan key:generate


In windows OS, you can open command prompt, change directory to your project directory.
Example,
My project directory

E:\xampp\htdocs\my_project


You can type into your Command prompt like this (hit enter each line):

E:cd xampp\htdocs\my_project

Then you can type,

copy .env.example .env

If you are using Linux, you can type cp, instead of copy


I had this problem of no .env files showing up in the project.

Turns out the IDE I was using (Netbeans, try not to judge) will show certain types of .hidden files but not all.

After racking my brains for a bit I checked the file system and found the .env + .env.example files / modified them with a text editor.

Leaving this answer for the rare situation someones using a dodgy IDE like myself.