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?
In the explorer panel, click on the New File button as shown in the following screenshot: Then simply type in the new file name . env ...
. env file, as its name suggest, is a local where you put all your environment setup, such as database credentials, cache drivers and etc. Everything that is about the server that the project is running, and may have different values for different servers, are setup here.
env file must be in the root directory of your Laravel app. There's no way to change the file location (and I think there's no point too). Moreover, the root folder SHOULDN'T be a public folder, as . env shouldn't be exposed to a public access, otherwise the main security aim of it would be completely lost.
Just tried both ways and in both ways I got generated .env
file:
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With