gpt4 book ai didi

Laravel - 为什么 Laravel 要求将 .env.example 重命名为 .env 而 .env 已经存在?

转载 作者:行者123 更新时间:2023-12-01 11:12:34 37 4
gpt4 key购买 nike

在 Laravel 6 中 Documentation Application Key的第二段是这样写的

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!

他们为什么要求重命名它?我在 Laravel 旧版本中也找到了这段话。它们具有相同的内容但不同的名称,它们之间有什么区别吗?

最佳答案

如果你使用 composer 命令安装了 Laravel。

composer create-project laravel/laravel projectname

您不需要将 .env.example 文件重命名为 .env。如果您通过 Composer 或 Laravel 安装程序安装了 Laravel,则此 key 已通过 php artisan key:generate 命令为您设置。

如果您使用 git clone 克隆项目,一些文件夹会被 git 忽略,因此您可能无法获得 env 文件和 vendor 文件夹。因此,他们必须手动输入 php artisan key:generate 才能让他们的应用正常运行。

More info SO answer

关于Laravel - 为什么 Laravel 要求将 .env.example 重命名为 .env 而 .env 已经存在?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58109837/

37 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com