为什么要在 forge 中重新安装存储库 laravel 更改 env 中的数据?
Why re-install repository in forge laravel change data in env?
在 forge laravel 中重新安装我的存储库之前,我备份了我的 env 文件
我在 forge laravel 中安装我的存储库后,env 中的数据发生了变化
有3个键改变了,分别是APP_KEY, DB_USERNAME, DB_PASSWORD
我想问的是:
我是像在备份环境中那样继续使用 APP_KEY, DB_USERNAME, DB_PASSWORD
,还是使用新的 APP_KEY, DB_USERNAME, DB_PASSWORD
?
composer.json
文件包含一些安装项目后 运行 的脚本:
"post-root-package-install": [
"php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-install-cmd": [
"Illuminate\Foundation\ComposerScripts::postInstall"
],
"post-update-cmd": [
"Illuminate\Foundation\ComposerScripts::postUpdate"
],
如果项目根目录中不存在.env
,则会将.env.example
复制到.env
。在那之后,php artisan key:generate
是 运行,它设置了新的 APP_KEY
.
当您处理一个新项目并且没有加密数据时,APP_KEY
并不重要。 DB_USERNAME
和 DB_PASSWORD
如果您已经有想要重新连接的数据库,您可能需要旧值。
来自 Laravel 文档:
Application Key
The next thing you should do after installing Laravel
is set your application key to a random string. If you installed
Laravel via Composer or the Laravel installer, this key has already
been set for you by the php artisan key:generate command.
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!
在 forge laravel 中重新安装我的存储库之前,我备份了我的 env 文件
我在 forge laravel 中安装我的存储库后,env 中的数据发生了变化
有3个键改变了,分别是APP_KEY, DB_USERNAME, DB_PASSWORD
我想问的是:
我是像在备份环境中那样继续使用 APP_KEY, DB_USERNAME, DB_PASSWORD
,还是使用新的 APP_KEY, DB_USERNAME, DB_PASSWORD
?
composer.json
文件包含一些安装项目后 运行 的脚本:
"post-root-package-install": [
"php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-install-cmd": [
"Illuminate\Foundation\ComposerScripts::postInstall"
],
"post-update-cmd": [
"Illuminate\Foundation\ComposerScripts::postUpdate"
],
如果项目根目录中不存在.env
,则会将.env.example
复制到.env
。在那之后,php artisan key:generate
是 运行,它设置了新的 APP_KEY
.
当您处理一个新项目并且没有加密数据时,APP_KEY
并不重要。 DB_USERNAME
和 DB_PASSWORD
如果您已经有想要重新连接的数据库,您可能需要旧值。
来自 Laravel 文档:
Application Key
The next thing you should do after installing Laravel is set your application key to a random string. If you installed Laravel via Composer or the Laravel installer, this key has already been set for you by the php artisan key:generate command.
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!