Laravel - 为什么 laravel 要求将 .env.example 重命名为 .env 而 .env 已经存在?
Laravel - Why laravel ask to rename .env.example to .env while .env already exist?
在Laravel 6Documentation的第二段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 旧版本中找到了这段话。两者内容相同但名称不同,有什么区别吗?
Laravel需要使用.env
文件来定义数据库连接,一些通用设置如application key
也是如此。因此,如果您没有 .env
文件,则您的 Laravel 目前还没有设置。
正如他们所说,If the application key is not set, your user sessions and other encrypted data will not be secure!
出于这个原因,您需要创建/复制/删除 .env.example
到新的.env
。让我们的 Laravel 了解一般配置。
顺便说一句,不要像复制粘贴那样使用.env.example
,因为它只是一个例子。您需要将值配置更改为您自己的配置。
如果您使用 composer 命令安装 Laravel。
composer create-project laravel/laravel projectname
您不需要将 .env.example
文件重命名为 .env
。如果您通过 Composer 或 Laravel 安装程序安装 Laravel,则此密钥已由 php artisan key:generate
命令为您设置。
如果您使用 git clone
克隆项目,某些文件夹会被 git 忽略,因此您可能无法获得环境文件和供应商文件夹。因此,他们必须手动输入 php artisan key:generate
才能使他们的应用程序正常运行。
.env.example
文件只是.env
文件的一个例子。应用程序不使用它。用作您编辑和重命名的基础。
在全新的 Laravel 安装中,应用程序的根目录将包含一个 .env.example
文件。如果您通过 Composer 安装 Laravel ,该文件将自动重命名为 .env
。否则,您应该手动重命名文件。
最简单的方法是使用 Filezilla
或其他 FTP 程序将其移动到您的 server
上。 Rename file
,re-download
它在你的 computer
上。上次对我有用:)
在Laravel 6Documentation的第二段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 旧版本中找到了这段话。两者内容相同但名称不同,有什么区别吗?
Laravel需要使用.env
文件来定义数据库连接,一些通用设置如application key
也是如此。因此,如果您没有 .env
文件,则您的 Laravel 目前还没有设置。
正如他们所说,If the application key is not set, your user sessions and other encrypted data will not be secure!
出于这个原因,您需要创建/复制/删除 .env.example
到新的.env
。让我们的 Laravel 了解一般配置。
顺便说一句,不要像复制粘贴那样使用.env.example
,因为它只是一个例子。您需要将值配置更改为您自己的配置。
如果您使用 composer 命令安装 Laravel。
composer create-project laravel/laravel projectname
您不需要将 .env.example
文件重命名为 .env
。如果您通过 Composer 或 Laravel 安装程序安装 Laravel,则此密钥已由 php artisan key:generate
命令为您设置。
如果您使用 git clone
克隆项目,某些文件夹会被 git 忽略,因此您可能无法获得环境文件和供应商文件夹。因此,他们必须手动输入 php artisan key:generate
才能使他们的应用程序正常运行。
.env.example
文件只是.env
文件的一个例子。应用程序不使用它。用作您编辑和重命名的基础。
在全新的 Laravel 安装中,应用程序的根目录将包含一个 .env.example
文件。如果您通过 Composer 安装 Laravel ,该文件将自动重命名为 .env
。否则,您应该手动重命名文件。
最简单的方法是使用 Filezilla
或其他 FTP 程序将其移动到您的 server
上。 Rename file
,re-download
它在你的 computer
上。上次对我有用:)