How to generate .env file for laravel?

前端 未结 10 1035
不知归路
不知归路 2020-12-24 05:39

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

$laravel new blog

or via composer:



        
相关标签:
10条回答
  • 2020-12-24 06:26

    There's another explanation for why .env doesn't exist, and it happens when you move all the Laravel files.

    Take this workflow: in your project directory you do laravel new whatever, Laravel is installed in whatever, you do mv * .. to move all the files to your project folder, and you remove whatever. The problem is, mv doesn't move hidden files by default, so the .env files are left behind, and are removed!

    0 讨论(0)
  • 2020-12-24 06:28

    create .env using command!

    composer run post-root-package-install or sudo composer run post-root-package-install

    0 讨论(0)
  • 2020-12-24 06:30

    in console (cmd), go to app root path and execute:

    type .env.example > .env
    
    0 讨论(0)
  • 2020-12-24 06:31

    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
    
    0 讨论(0)
提交回复
热议问题