How to generate .env file for laravel?

koalaok picture koalaok · Apr 28, 2015 · Viewed 189.2k times · Source

From the documentation I see it's possible to create a laravel project via laravel installer:

$laravel new blog

or via composer:

$composer create-project laravel/laravel --prefer-dist

If I try the first way .env file is not created. How can I ask laravel,artisan or composer to create a .env file for me?

Answer

Limon Monte picture Limon Monte · Apr 28, 2015

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 .env
php artisan key:generate